From 622d488fc3062e01df0d889d0738cd3c987fb2a8 Mon Sep 17 00:00:00 2001 From: Monis Khan Date: Tue, 7 Jul 2020 21:42:14 -0400 Subject: [PATCH] Add integration test stub Signed-off-by: Monis Khan --- test/integration/kubectl_test.go | 13 +++++++++++++ test/integration/main_test.go | 28 ++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 test/integration/kubectl_test.go create mode 100644 test/integration/main_test.go diff --git a/test/integration/kubectl_test.go b/test/integration/kubectl_test.go new file mode 100644 index 00000000..c8b15b3e --- /dev/null +++ b/test/integration/kubectl_test.go @@ -0,0 +1,13 @@ +package integration + +import ( + "os/exec" + "testing" + + "github.com/stretchr/testify/require" +) + +func TestGetNodes(t *testing.T) { + err := exec.Command("kubectl", "get", "nodes").Run() + require.NoError(t, err) +} diff --git a/test/integration/main_test.go b/test/integration/main_test.go new file mode 100644 index 00000000..75afd53b --- /dev/null +++ b/test/integration/main_test.go @@ -0,0 +1,28 @@ +package integration + +import ( + "fmt" + "os" + "strconv" + "testing" +) + +// force users to opt-in to running the integration tests +// this prevents them from running if someone does `go test ./...` +// these tests could be destructive to the cluster under test +const magicIntegrationTestsEnvVar = "NAME_TEST_INTEGRATION" + +var shouldRunIntegrationTests bool + +func init() { + shouldRunIntegrationTests, _ = strconv.ParseBool(os.Getenv(magicIntegrationTestsEnvVar)) +} + +func TestMain(m *testing.M) { + if !shouldRunIntegrationTests { + fmt.Printf("SKIP: %s=true env var must be explicitly set for integration tests to run\n", magicIntegrationTestsEnvVar) + os.Exit(0) + } + + os.Exit(m.Run()) +}