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

Missing test case when handling docker context - continuation of the solution to fix 1759 #1894

Merged
merged 2 commits into from
Sep 12, 2023
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
3 changes: 3 additions & 0 deletions internal/docker/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ func readConfigFile(configDir string) (*configFile, error) {
config := &configFile{}
file, err := os.Open(filename)
if err != nil {
if os.IsNotExist(err) {
return &configFile{}, nil
}
return &configFile{}, err
}
defer file.Close()
Expand Down
24 changes: 24 additions & 0 deletions internal/docker/context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,30 @@ func testProcessDockerContext(t *testing.T, when spec.G, it spec.S) {
h.AssertContains(t, strings.TrimSpace(outBuf.String()), "docker context is default or empty, skipping it")
})
})

when("docker config folder doesn't exists", func() {
it.Before(func() {
setDockerConfig(t, errorCase, "no-docker-folder")
})

it("docker context process is skip", func() {
err := docker.ProcessDockerContext(logger)
h.AssertNil(t, err)
h.AssertContains(t, strings.TrimSpace(outBuf.String()), "docker context is default or empty, skipping it")
})
})

when("config.json config doesn't exists", func() {
it.Before(func() {
setDockerConfig(t, errorCase, "config-does-not-exist")
})

it("docker context process is skip", func() {
err := docker.ProcessDockerContext(logger)
h.AssertNil(t, err)
h.AssertContains(t, strings.TrimSpace(outBuf.String()), "docker context is default or empty, skipping it")
})
})
})
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This folder is intentionally empty to test the scenario when the docker config.json file doesn't exist
Loading