From 2e9fe1c38a0f503115439b1da0665e1218e2d8b7 Mon Sep 17 00:00:00 2001 From: hazelmayank Date: Fri, 8 May 2026 18:17:34 +0000 Subject: [PATCH] test: use temporary config file in context delete test Signed-off-by: hazelmayank --- cmd/context_test.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/cmd/context_test.go b/cmd/context_test.go index 8de7935..2de3cf4 100644 --- a/cmd/context_test.go +++ b/cmd/context_test.go @@ -2,6 +2,7 @@ package cmd import ( "os" + "path/filepath" "testing" "github.com/microcks/microcks-cli/pkg/config" @@ -36,15 +37,13 @@ users: auth-token: "" refresh-token: ""` -const testConfigFilePath = "./testdata/local.config" - func TestDeleteContext(t *testing.T) { - //write the test config file - err := os.WriteFile(testConfigFilePath, []byte(testConfig), os.ModePerm) + testConfigFilePath := filepath.Join(t.TempDir(), "local.config") + + // write the test config file + err := os.WriteFile(testConfigFilePath, []byte(testConfig), 0o600) require.NoError(t, err) - err = os.Chmod(testConfigFilePath, 0o600) - require.NoError(t, err, "Could not change the file permission to 0600 %v", err) localCfg, err := config.ReadLocalConfig(testConfigFilePath) require.NoError(t, err) assert.Equal(t, "http://localhost:8083", localCfg.CurrentContext)