diff --git a/cmd/meroxa/root/apps/describe_test.go b/cmd/meroxa/root/apps/describe_test.go index 991479905..7ef18207b 100644 --- a/cmd/meroxa/root/apps/describe_test.go +++ b/cmd/meroxa/root/apps/describe_test.go @@ -165,7 +165,7 @@ func TestDescribeApplicationExecutionWithPath(t *testing.T) { i := &Init{ logger: logger, } - path := "tmp" + uuid.NewString() + path := filepath.Join(os.TempDir(), uuid.NewString()) i.args.appName = appName i.flags.Path = path i.flags.Lang = string(ir.GoLang) diff --git a/cmd/meroxa/root/apps/init_test.go b/cmd/meroxa/root/apps/init_test.go index 6eba96241..f3d97066d 100644 --- a/cmd/meroxa/root/apps/init_test.go +++ b/cmd/meroxa/root/apps/init_test.go @@ -138,7 +138,7 @@ func TestGoInitExecute(t *testing.T) { { desc: "Init without go mod init because the path is not under GOPATH and with vendor flag", path: func() string { - return filepath.Join("/tmp", uuid.New().String()) //nolint:gocritic + return filepath.Join(os.TempDir(), uuid.New().String()) //nolint:gocritic }(), skipModInit: false, effectiveSkipModInit: true, @@ -168,13 +168,13 @@ func TestGoInitExecute(t *testing.T) { if err == nil && tt.err == nil { if !tt.skipModInit && !tt.effectiveSkipModInit { - p, _ := filepath.Abs(tt.path + "/" + cc.args.appName + "/go.mod") + p, _ := filepath.Abs(filepath.Join(tt.path, cc.args.appName, "go.mod")) if _, err := os.Stat(p); os.IsNotExist(err) { t.Fatalf("expected file \"%s\" to be created", p) } if tt.vendor { - p, _ = filepath.Abs(tt.path + "/" + cc.args.appName + "/go.mod") + p, _ = filepath.Abs(filepath.Join(tt.path, cc.args.appName, "go.mod")) if _, err := os.Stat(p); os.IsNotExist(err) { t.Fatalf("expected directory \"%s\" to be created", p) } @@ -252,7 +252,7 @@ func TestJsPyAndRbInitExecute(t *testing.T) { mock := mockturbinecli.NewMockCLI(mockCtrl) if tt.err == nil { mock.EXPECT().Init(ctx, tt.name) - mock.EXPECT().GitInit(ctx, tt.path+"/"+tt.name) + mock.EXPECT().GitInit(ctx, filepath.Join(tt.path, tt.name)) } else { mock.EXPECT().Init(ctx, tt.name).Return(tt.err) } diff --git a/cmd/meroxa/root/apps/logs_test.go b/cmd/meroxa/root/apps/logs_test.go index e132f550e..3f79e8cc4 100644 --- a/cmd/meroxa/root/apps/logs_test.go +++ b/cmd/meroxa/root/apps/logs_test.go @@ -134,7 +134,7 @@ func TestApplicationLogsExecutionWithPath(t *testing.T) { i := &Init{ logger: logger, } - path, _ := filepath.Abs("tmp" + uuid.NewString()) + path, _ := filepath.Abs(filepath.Join(os.TempDir(), uuid.NewString())) i.args.appName = appName i.flags.Path = path i.flags.Lang = string(ir.GoLang) diff --git a/cmd/meroxa/root/apps/open_test.go b/cmd/meroxa/root/apps/open_test.go index 220de601d..2d2de3c60 100644 --- a/cmd/meroxa/root/apps/open_test.go +++ b/cmd/meroxa/root/apps/open_test.go @@ -106,14 +106,14 @@ func TestOpenAppExecution(t *testing.T) { }, { desc: "Fail with bad path", - appFlag: "/tmp", + appFlag: os.TempDir(), wantErr: errors.New("could not find an app.json file on path"), }, } for _, tc := range testCases { t.Run(tc.desc, func(t *testing.T) { os.Setenv("UNIT_TEST", "1") - path := filepath.Join("/tmp", uuid.New().String()) + path := filepath.Join(os.TempDir(), uuid.New().String()) logger := log.NewTestLogger() cc := &Init{} cc.Logger(logger) diff --git a/cmd/meroxa/root/apps/remove_test.go b/cmd/meroxa/root/apps/remove_test.go index 27b231fdc..db463fc32 100644 --- a/cmd/meroxa/root/apps/remove_test.go +++ b/cmd/meroxa/root/apps/remove_test.go @@ -134,7 +134,7 @@ func TestRemoveAppExecutionWithPath(t *testing.T) { i := &Init{ logger: logger, } - path := "tmp" + uuid.NewString() + path := filepath.Join(os.TempDir(), uuid.NewString()) i.args.appName = app.Name i.flags.Path = path i.flags.Lang = string(ir.GoLang) diff --git a/cmd/meroxa/root/resources/create_test.go b/cmd/meroxa/root/resources/create_test.go index 59cf90ee5..0f9dae8a6 100644 --- a/cmd/meroxa/root/resources/create_test.go +++ b/cmd/meroxa/root/resources/create_test.go @@ -372,7 +372,7 @@ func TestCreateResourceExecutionPrivateKeyFlags(t *testing.T) { logger := log.NewTestLogger() keyVal := "super-secret" - keyFile := filepath.Join("/tmp", uuid.NewString()) + keyFile := filepath.Join(os.TempDir(), uuid.NewString()) err := os.WriteFile(keyFile, []byte(keyVal), 0o600) require.NoError(t, err) diff --git a/cmd/meroxa/turbine/utils_test.go b/cmd/meroxa/turbine/utils_test.go index 4e9213492..4020a6640 100644 --- a/cmd/meroxa/turbine/utils_test.go +++ b/cmd/meroxa/turbine/utils_test.go @@ -317,7 +317,7 @@ func Test_trimNonNpmErrorLines(t *testing.T) { } func makeTmpDir() (string, error) { - basePath := "/tmp" + basePath := os.TempDir() dirName := uuid.NewString() appPath := filepath.Join(basePath, dirName) err := os.MkdirAll(appPath, os.ModePerm)