From c77a0900033bbef4cf03071f872add6b375739ca Mon Sep 17 00:00:00 2001 From: The Magician Date: Tue, 18 Feb 2020 09:40:08 -0800 Subject: [PATCH] Avoid panics on unit tests (#3134) (#1767) Signed-off-by: Modular Magician --- .changelog/3134.txt | 3 +++ google-beta/bootstrap_utils_test.go | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 .changelog/3134.txt diff --git a/.changelog/3134.txt b/.changelog/3134.txt new file mode 100644 index 0000000000..dbe863b82b --- /dev/null +++ b/.changelog/3134.txt @@ -0,0 +1,3 @@ +```release-note:none +no release note, test fixes +``` diff --git a/google-beta/bootstrap_utils_test.go b/google-beta/bootstrap_utils_test.go index 6f141caf4e..8700391b95 100644 --- a/google-beta/bootstrap_utils_test.go +++ b/google-beta/bootstrap_utils_test.go @@ -53,7 +53,7 @@ func BootstrapKMSKeyWithPurpose(t *testing.T, purpose string) bootstrappedKMS { **/ func BootstrapKMSKeyWithPurposeInLocation(t *testing.T, purpose, locationID string) bootstrappedKMS { if v := os.Getenv("TF_ACC"); v == "" { - log.Println("Acceptance tests and bootstrapping skipped unless env 'TF_ACC' set") + t.Skip("Acceptance tests and bootstrapping skipped unless env 'TF_ACC' set") // If not running acceptance tests, return an empty object return bootstrappedKMS{ @@ -204,7 +204,7 @@ func impersonationServiceAccountPermissions(config *Config, sa *iam.ServiceAccou func BootstrapServiceAccount(t *testing.T, project, testRunner string) string { if v := os.Getenv("TF_ACC"); v == "" { - log.Println("Acceptance tests and bootstrapping skipped unless env 'TF_ACC' set") + t.Skip("Acceptance tests and bootstrapping skipped unless env 'TF_ACC' set") return "" } @@ -246,7 +246,7 @@ const SharedTestNetworkPrefix = "tf-bootstrap-net-" // Returns the name of an network, creating it if hasn't been created in the test projcet. func BootstrapSharedTestNetwork(t *testing.T, testId string) string { if v := os.Getenv("TF_ACC"); v == "" { - log.Println("Acceptance tests and bootstrapping skipped unless env 'TF_ACC' set") + t.Skip("Acceptance tests and bootstrapping skipped unless env 'TF_ACC' set") // If not running acceptance tests, return an empty string return "" } @@ -300,7 +300,7 @@ var SharedServicePerimeterProjectPrefix = "tf-bootstrap-sp-" func BootstrapServicePerimeterProjects(t *testing.T, desiredProjects int) []*cloudresourcemanager.Project { if v := os.Getenv("TF_ACC"); v == "" { - log.Println("Acceptance tests and bootstrapping skipped unless env 'TF_ACC' set") + t.Skip("Acceptance tests and bootstrapping skipped unless env 'TF_ACC' set") return nil }