Add integration test stub

Signed-off-by: Monis Khan <mok@vmware.com>
This commit is contained in:
Monis Khan 2020-07-07 21:42:14 -04:00
parent f0d7077efc
commit 622d488fc3
No known key found for this signature in database
GPG Key ID: 52C90ADA01B269B8
2 changed files with 41 additions and 0 deletions

View File

@ -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)
}

View File

@ -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())
}