MCPcopy Index your code
hub / github.com/docker/cli / TestRunBuildFromGitHubSpecialCase

Function TestRunBuildFromGitHubSpecialCase

cli/command/image/build_test.go:121–131  ·  view source on GitHub ↗

TestRunBuildFromGitHubSpecialCase tests that build contexts starting with `github.com/` are special-cased, and the build command attempts to clone the remote repo. TODO: test "context selection" logic directly when runBuild is refactored to support testing (ex: docker/cli#294)

(t *testing.T)

Source from the content-addressed store, hash-verified

119// TODO: test "context selection" logic directly when runBuild is refactored
120// to support testing (ex: docker/cli#294)
121func TestRunBuildFromGitHubSpecialCase(t *testing.T) {
122 t.Setenv("DOCKER_BUILDKIT", "0")
123 cmd := newBuildCommand(test.NewFakeCli(&fakeClient{}))
124 // Clone a small repo that exists so git doesn't prompt for credentials
125 cmd.SetArgs([]string{"github.com/docker/for-win"})
126 cmd.SetOut(io.Discard)
127 cmd.SetErr(io.Discard)
128 err := cmd.Execute()
129 assert.ErrorContains(t, err, "unable to prepare context")
130 assert.ErrorContains(t, err, "docker-build-git")
131}
132
133// TestRunBuildFromLocalGitHubDir tests that a local directory
134// starting with `github.com` takes precedence over the `github.com` special

Callers

nothing calls this directly

Calls 4

newBuildCommandFunction · 0.85
SetArgsMethod · 0.80
SetOutMethod · 0.45
SetErrMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…