MCPcopy Create free account
hub / github.com/containerd/nerdctl / TestComposeIPAMConfig

Function TestComposeIPAMConfig

cmd/nerdctl/compose/compose_up_linux_test.go:558–602  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

556}
557
558func TestComposeIPAMConfig(t *testing.T) {
559 testCase := nerdtest.Setup()
560
561 testCase.Setup = func(data test.Data, helpers test.Helpers) {
562 var composeYAML = fmt.Sprintf(`
563services:
564 foo:
565 image: %s
566 command: "sleep infinity"
567
568networks:
569 default:
570 ipam:
571 config:
572 - subnet: 10.1.100.0/24
573`, testutil.CommonImage)
574
575 composePath := data.Temp().Save(composeYAML, "compose.yaml")
576
577 projectName := filepath.Base(filepath.Dir(composePath))
578 t.Logf("projectName=%q", projectName)
579
580 fooContainer := serviceparser.DefaultContainerName(projectName, "foo", "1")
581
582 data.Labels().Set("composeYAML", composePath)
583 data.Labels().Set("fooContainer", fooContainer)
584
585 helpers.Ensure("compose", "-f", composePath, "up", "-d")
586 nerdtest.EnsureContainerStarted(helpers, fooContainer)
587 }
588
589 testCase.Command = func(data test.Data, helpers test.Helpers) test.TestableCommand {
590 return helpers.Command("inspect", "-f", "{{json .NetworkSettings.Networks }}", data.Labels().Get("fooContainer"))
591 }
592
593 testCase.Expected = test.Expects(0, nil, expect.Contains("10.1.100."))
594
595 testCase.Cleanup = func(data test.Data, helpers test.Helpers) {
596 if data.Labels().Get("composeYAML") != "" {
597 helpers.Anyhow("compose", "-f", data.Labels().Get("composeYAML"), "down", "-v")
598 }
599 }
600
601 testCase.Run(t)
602}
603
604func TestComposeUpRemoveOrphans(t *testing.T) {
605 testCase := nerdtest.Setup()

Callers

nothing calls this directly

Calls 13

SetupFunction · 0.92
DefaultContainerNameFunction · 0.92
EnsureContainerStartedFunction · 0.92
SaveMethod · 0.65
TempMethod · 0.65
DirMethod · 0.65
SetMethod · 0.65
LabelsMethod · 0.65
EnsureMethod · 0.65
CommandMethod · 0.65
GetMethod · 0.65
AnyhowMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…