MCPcopy
hub / github.com/docker/compose / TestBuildImageDependencies

Function TestBuildImageDependencies

pkg/e2e/build_test.go:241–296  ·  pkg/e2e/build_test.go::TestBuildImageDependencies
(t *testing.T)

Source from the content-addressed store, hash-verified

239}
240
241func TestBuildImageDependencies(t *testing.T) {
242 doTest := func(t *testing.T, cli *CLI, args ...string) {
243 resetState := func() {
244 cli.RunDockerComposeCmd(t, "down", "--rmi=all", "-t=0")
245 res := cli.RunDockerOrExitError(t, "image", "rm", "build-dependencies-service")
246 if res.Error != nil {
247 assert.Assert(t, is.Contains(res.Stderr(), `No such image: build-dependencies-service`))
248 }
249 }
250 resetState()
251 t.Cleanup(resetState)
252
253 // the image should NOT exist now
254 res := cli.RunDockerOrExitError(t, "image", "inspect", "build-dependencies-service")
255 res.Assert(t, icmd.Expected{
256 ExitCode: 1,
257 Err: "No such image: build-dependencies-service",
258 })
259
260 res = cli.RunDockerComposeCmd(t, args...)
261 t.Log(res.Combined())
262
263 res = cli.RunDockerCmd(t,
264 "image", "inspect", "--format={{ index .RepoTags 0 }}",
265 "build-dependencies-service")
266 res.Assert(t, icmd.Expected{Out: "build-dependencies-service:latest"})
267
268 res = cli.RunDockerComposeCmd(t, "down", "-t0", "--rmi=all", "--remove-orphans")
269 t.Log(res.Combined())
270
271 res = cli.RunDockerOrExitError(t, "image", "inspect", "build-dependencies-service")
272 res.Assert(t, icmd.Expected{
273 ExitCode: 1,
274 Err: "No such image: build-dependencies-service",
275 })
276 }
277
278 t.Run("ClassicBuilder", func(t *testing.T) {
279 cli := NewCLI(t, WithEnv(
280 "DOCKER_BUILDKIT=0",
281 "COMPOSE_FILE=./fixtures/build-dependencies/classic.yaml",
282 ))
283 doTest(t, cli, "build")
284 doTest(t, cli, "build", "--with-dependencies", "service")
285 })
286
287 t.Run("Bake by additional contexts", func(t *testing.T) {
288 cli := NewCLI(t, WithEnv(
289 "DOCKER_BUILDKIT=1", "COMPOSE_BAKE=1",
290 "COMPOSE_FILE=./fixtures/build-dependencies/compose.yaml",
291 ))
292 doTest(t, cli, "--verbose", "build")
293 doTest(t, cli, "--verbose", "build", "service")
294 doTest(t, cli, "--verbose", "up", "--build", "service")
295 })
296}
297
298func TestBuildPlatformsWithCorrectBuildxConfig(t *testing.T) {

Callers

nothing calls this directly

Calls 7

RunDockerComposeCmdMethod · 0.95
RunDockerOrExitErrorMethod · 0.95
RunDockerCmdMethod · 0.95
NewCLIFunction · 0.85
WithEnvFunction · 0.85
doTestFunction · 0.85
LogMethod · 0.65

Tested by

no test coverage detected