Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions pkg/creds/credentials_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1024,12 +1024,13 @@ func testHomeEnvName() string {
func testConfigPath(t *testing.T) string {
t.Helper()
home := os.Getenv(testHomeEnvName())
var configPath string
if home != "" { // if HOME is not set, don't create config dir
configPath = filepath.Join(home, ".config", "func")
if err := os.MkdirAll(configPath, os.ModePerm); err != nil {
t.Fatal(err)
}
// using a temp directory to avoid polluting the source tree with auth.json
if home == "" {
home = t.TempDir()
}
configPath := filepath.Join(home, ".config", "func")
if err := os.MkdirAll(configPath, os.ModePerm); err != nil {
t.Fatal(err)
}
return configPath
}
Expand All @@ -1039,6 +1040,9 @@ func testConfigPath(t *testing.T) string {
func testConfigPathError(t *testing.T) (string, error) {
t.Helper()
home := os.Getenv(testHomeEnvName())
if home == "" {
home = t.TempDir()
}
configPath := filepath.Join(home, ".config", "func")
return configPath, os.MkdirAll(configPath, os.ModePerm)
}
Expand Down
Loading