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

Function TestRunBuildDockerfileOutsideContext

cli/command/image/build_test.go:89–114  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

87}
88
89func TestRunBuildDockerfileOutsideContext(t *testing.T) {
90 t.Setenv("DOCKER_BUILDKIT", "0")
91 dir := fs.NewDir(t, t.Name(),
92 fs.WithFile("data", "data file"))
93 defer dir.Remove()
94
95 // Dockerfile outside of build-context
96 df := fs.NewFile(t, t.Name(),
97 fs.WithContent(`
98FROM FOOBAR
99COPY data /data
100 `),
101 )
102 defer df.Remove()
103
104 fakeBuild := newFakeBuild()
105 cli := test.NewFakeCli(&fakeClient{imageBuildFunc: fakeBuild.build})
106
107 options := newBuildOptions()
108 options.context = dir.Path()
109 options.dockerfileName = df.Path()
110 assert.NilError(t, runBuild(context.TODO(), cli, options))
111
112 expected := []string{fakeBuild.options.Dockerfile, ".dockerignore", "data"}
113 assert.DeepEqual(t, expected, fakeBuild.filenames(t))
114}
115
116// TestRunBuildFromGitHubSpecialCase tests that build contexts
117// starting with `github.com/` are special-cased, and the build command attempts

Callers

nothing calls this directly

Calls 7

newFakeBuildFunction · 0.85
newBuildOptionsFunction · 0.85
runBuildFunction · 0.85
filenamesMethod · 0.80
RemoveMethod · 0.65
PathMethod · 0.65
NameMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…