Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: nil docker auth test #2630

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@ func writeStaticConfig(t *testing.T, configContent string) string {
t.Fatalf("Failed to create temp directory: %v", err)
}

configPath := tmpDir + "/config.json"
err = os.WriteFile(configPath, []byte(configContent), 0600)
if err != nil {
t.Fatalf("Failed to write config.json: %v", err)
// only set auth if content is empty
if configContent != "" {
configPath := tmpDir + "/config.json"
err = os.WriteFile(configPath, []byte(configContent), 0600)
if err != nil {
t.Fatalf("Failed to write config.json: %v", err)
}
}

// Set the DOCKER_CONFIG environment variable to the temp directory
Expand All @@ -28,6 +31,9 @@ func writeStaticConfig(t *testing.T, configContent string) string {
}

func TestGetAuthWithNoAuthSetReturnsNilAndNoError(t *testing.T) {
// update docker config env var
tmpDir := writeStaticConfig(t, "")
defer os.RemoveAll(tmpDir)
authConfig, err := GetAuthFromDockerConfig("my-repo/my-image:latest")
assert.NoError(t, err)
assert.Nil(t, authConfig, "Auth config should be nil")
Expand Down
Loading