From 8a6214fc87b9ec4ad2cefd92d9941805967dfb0a Mon Sep 17 00:00:00 2001 From: Vipin Kumar Date: Tue, 24 Dec 2024 12:38:20 +0530 Subject: [PATCH] test: Continuous test case failure fix --- tests/other_test.go | 2 +- tests/pr_test.go | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/tests/other_test.go b/tests/other_test.go index e7a2f60..e746ae0 100644 --- a/tests/other_test.go +++ b/tests/other_test.go @@ -35,7 +35,7 @@ func TestRunCompleteExample(t *testing.T) { if err1 != nil { log.Fatalf("Error getting current working directory: %v", err1) } - sigDirectory = cwd + "/keys" + sigDirectory := cwd + "/keys" admins, err := CreateSigKeys(usernames, sigDirectory) if !assert.Nilf(t, err, "Error creating sigkeys: %v", err) { diff --git a/tests/pr_test.go b/tests/pr_test.go index f19bd25..2ad2e95 100644 --- a/tests/pr_test.go +++ b/tests/pr_test.go @@ -18,8 +18,6 @@ import ( // Use existing resource group // const resourceGroup = "geretain-test-resources" -var sigDirectory string - // Note: if this is needed again in another module move the code to github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper // CreateSigKeys generates signature keys for the provided usernames and stores them in the specified output directory. @@ -87,11 +85,6 @@ func CreateSigKeys(usernames []string, outputDir string) (string, error) { } func TestMain(m *testing.M) { - cwd, err := os.Getwd() - if err != nil { - log.Fatalf("Error getting current working directory: %v", err) - } - sigDirectory = cwd + "/sigs" os.Exit(m.Run()) } @@ -116,6 +109,12 @@ func TestRunUpgradeExample(t *testing.T) { usernames := []string{"admin1"} + cwd, err := os.Getwd() + if err != nil { + log.Fatalf("Error getting current working directory: %v", err) + } + sigDirectory := cwd + "/sigs" + admins, err := CreateSigKeys(usernames, sigDirectory) if !assert.Nilf(t, err, "Error creating sigkeys: %v", err) { log.Fatalf("Error creating sigkeys: %v", err)