Early skip mssql test if not on acceptance, defer Teardown() early in testing.Test (#4457)

This commit is contained in:
Calvin Leung Huang 2018-04-26 12:17:44 -04:00 committed by GitHub
parent 6fc57a91d8
commit 1bbdc2ce84
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 5 deletions

View file

@ -104,6 +104,10 @@ func TestBackend_config_connection(t *testing.T) {
}
func TestBackend_basic(t *testing.T) {
if os.Getenv(logicaltest.TestEnvVar) == "" {
t.Skip(fmt.Sprintf("Acceptance tests skipped unless env '%s' set", logicaltest.TestEnvVar))
}
b, _ := Factory(context.Background(), logical.TestBackendConfig())
cleanup, connURL := prepareMSSQLTestContainer(t)
@ -122,6 +126,10 @@ func TestBackend_basic(t *testing.T) {
}
func TestBackend_roleCrud(t *testing.T) {
if os.Getenv(logicaltest.TestEnvVar) == "" {
t.Skip(fmt.Sprintf("Acceptance tests skipped unless env '%s' set", logicaltest.TestEnvVar))
}
b := Backend()
cleanup, connURL := prepareMSSQLTestContainer(t)
@ -142,6 +150,10 @@ func TestBackend_roleCrud(t *testing.T) {
}
func TestBackend_leaseWriteRead(t *testing.T) {
if os.Getenv(logicaltest.TestEnvVar) == "" {
t.Skip(fmt.Sprintf("Acceptance tests skipped unless env '%s' set", logicaltest.TestEnvVar))
}
b := Backend()
cleanup, connURL := prepareMSSQLTestContainer(t)

View file

@ -128,6 +128,11 @@ func Test(tt TestT, c TestCase) {
c.PreCheck()
}
// Defer on the teardown, regardless of pass/fail at this point
if c.Teardown != nil {
defer c.Teardown()
}
// Check that something is provided
if c.Backend == nil && c.Factory == nil {
tt.Fatal("Must provide either Backend or Factory")
@ -334,11 +339,6 @@ func Test(tt TestT, c TestCase) {
s))
}
}
// Cleanup
if c.Teardown != nil {
c.Teardown()
}
}
// TestCheckMulti is a helper to have multiple checks.