mirror of
https://github.com/hashicorp/vault.git
synced 2026-05-28 04:10:44 -04:00
Early skip mssql test if not on acceptance, defer Teardown() early in testing.Test (#4457)
This commit is contained in:
parent
6fc57a91d8
commit
1bbdc2ce84
2 changed files with 17 additions and 5 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Reference in a new issue