Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,3 @@ __pycache__
# TODO: Update this test to be from a temp directory with a hard-coded impl:
# https://github.com/knative/func/issues/3196
/pkg/builders/testdata/go-fn-with-private-deps/.s2i

# TODO: update the test which creates this to run in a temp directory:
# https://github.com/knative/func/issues/3158
/pkg/creds/auth.json
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