Skip to content

Commit

Permalink
Avoid panics on unit tests (#3134) (#1767)
Browse files Browse the repository at this point in the history
Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored Feb 18, 2020
1 parent 7ba30db commit c77a090
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .changelog/3134.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:none
no release note, test fixes
```
8 changes: 4 additions & 4 deletions google-beta/bootstrap_utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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 ""
}

Expand Down Expand Up @@ -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 ""
}
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit c77a090

Please sign in to comment.