From bccfcf90d60aafdf986be9c97fd57cd1e940684d Mon Sep 17 00:00:00 2001 From: Flavio Castelli Date: Mon, 19 Feb 2018 16:35:45 +0100 Subject: Fix broken tests on Travis Some tests on travis are failing because there's no libvirt daemon running. Marking these tests as acceptance tests. --- libvirt/provider_test.go | 6 ++++++ libvirt/utils_libvirt_test.go | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/libvirt/provider_test.go b/libvirt/provider_test.go index 75f4d418..629f4306 100644 --- a/libvirt/provider_test.go +++ b/libvirt/provider_test.go @@ -2,6 +2,7 @@ package libvirt import ( "os" + "strings" "testing" "github.com/hashicorp/terraform/helper/schema" @@ -35,3 +36,8 @@ func testAccPreCheck(t *testing.T) { t.Fatal("LIBVIRT_DEFAULT_URI must be set for acceptance tests") } } + +func testAccEnabled() bool { + v := os.Getenv("TF_ACC") + return v == "1" || strings.ToLower(v) == "true" +} diff --git a/libvirt/utils_libvirt_test.go b/libvirt/utils_libvirt_test.go index e735d105..abaaea30 100644 --- a/libvirt/utils_libvirt_test.go +++ b/libvirt/utils_libvirt_test.go @@ -47,6 +47,10 @@ func connect(t *testing.T) *libvirt.Connect { } func TestGetHostArchitecture(t *testing.T) { + if !testAccEnabled() { + t.Logf("Acceptance tests skipped unless env 'TF_ACC' set") + return + } conn := connect(t) defer conn.Close() @@ -65,6 +69,10 @@ func TestGetHostArchitecture(t *testing.T) { } func TestGetCanonicalMachineName(t *testing.T) { + if !testAccEnabled() { + t.Logf("Acceptance tests skipped unless env 'TF_ACC' set") + return + } conn := connect(t) defer conn.Close() @@ -88,6 +96,11 @@ func TestGetCanonicalMachineName(t *testing.T) { } func TestGetOriginalMachineName(t *testing.T) { + if !testAccEnabled() { + t.Logf("Acceptance tests skipped unless env 'TF_ACC' set") + return + } + conn := connect(t) defer conn.Close() arch := "x86_64" @@ -115,6 +128,11 @@ func TestGetOriginalMachineName(t *testing.T) { } func TestGetHostCapabilties(t *testing.T) { + if !testAccEnabled() { + t.Logf("Acceptance tests skipped unless env 'TF_ACC' set") + return + } + start := time.Now() conn := connect(t) defer conn.Close() -- cgit v1.2.3