From 144e1c420cc13aa5fc4348f83606a81ed9df32d5 Mon Sep 17 00:00:00 2001 From: Markus Seidl Date: Fri, 2 Aug 2024 10:19:26 +0200 Subject: [PATCH] fix: Do not quietly exit, report errors! --- provider/provider_test.go | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/provider/provider_test.go b/provider/provider_test.go index 17bd9b47d..b455f8c5f 100644 --- a/provider/provider_test.go +++ b/provider/provider_test.go @@ -7,6 +7,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/meta" "github.com/qvest-digital/terraform-provider-keycloak/keycloak" + "log" "os" "testing" ) @@ -53,23 +54,17 @@ func TestMain(m *testing.M) { err := keycloakClient.DeleteRealm(testCtx, testAccRealm.Realm) if err != nil { - println("Unable to delete realm: " + testAccRealm.Realm) - println(err) - os.Exit(1) + log.Fatalf("Unable to delete realm %s: %s", testAccRealmUserFederation.Realm, err) } err = keycloakClient.DeleteRealm(testCtx, testAccRealmTwo.Realm) if err != nil { - println("Unable to delete realm: " + testAccRealmTwo.Realm) - println(err) - os.Exit(1) + log.Fatalf("Unable to delete realm %s: %s", testAccRealmUserFederation.Realm, err) } err = keycloakClient.DeleteRealm(testCtx, testAccRealmUserFederation.Realm) if err != nil { - println("Unable to delete realm: " + testAccRealmUserFederation.Realm) - println(err) - os.Exit(1) + log.Fatalf("Unable to delete realm %s: %s", testAccRealmUserFederation.Realm, err) } os.Exit(code) @@ -85,9 +80,7 @@ func createTestRealm(testCtx context.Context) *keycloak.Realm { err := keycloakClient.NewRealm(testCtx, r) if err != nil { - println("Unable to create realm: " + r.Realm) - println(err) - os.Exit(1) + log.Fatalf("Unable to create new realm: %s", err) } return r