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

Function TestComposeImages

cmd/nerdctl/compose/compose_images_linux_test.go:34–130  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

32)
33
34func TestComposeImages(t *testing.T) {
35 var dockerComposeYAML = fmt.Sprintf(`
36services:
37 wordpress:
38 image: %s
39 container_name: wordpress
40 environment:
41 WORDPRESS_DB_HOST: db
42 WORDPRESS_DB_USER: exampleuser
43 WORDPRESS_DB_PASSWORD: examplepass
44 WORDPRESS_DB_NAME: exampledb
45 volumes:
46 - wordpress:/var/www/html
47 db:
48 image: %s
49 container_name: db
50 environment:
51 MYSQL_DATABASE: exampledb
52 MYSQL_USER: exampleuser
53 MYSQL_PASSWORD: examplepass
54 MYSQL_RANDOM_ROOT_PASSWORD: '1'
55 volumes:
56 - db:/var/lib/mysql
57
58volumes:
59 wordpress:
60 db:
61`, testutil.WordpressImage, testutil.MariaDBImage)
62
63 wordpressImageName, _ := referenceutil.Parse(testutil.WordpressImage)
64 dbImageName, _ := referenceutil.Parse(testutil.MariaDBImage)
65
66 testCase := nerdtest.Setup()
67
68 testCase.Setup = func(data test.Data, helpers test.Helpers) {
69 data.Temp().Save(dockerComposeYAML, "compose.yaml")
70 data.Labels().Set("composeYaml", data.Temp().Path("compose.yaml"))
71 helpers.Ensure("compose", "-f", data.Temp().Path("compose.yaml"), "up", "-d")
72 }
73
74 testCase.Cleanup = func(data test.Data, helpers test.Helpers) {
75 helpers.Anyhow("compose", "-f", data.Temp().Path("compose.yaml"), "down")
76 }
77
78 testCase.SubTests = []*test.Case{
79 {
80 Description: "images db",
81 Command: func(data test.Data, helpers test.Helpers) test.TestableCommand {
82 return helpers.Command("compose", "-f", data.Labels().Get("composeYaml"), "images", "db")
83 },
84 Expected: test.Expects(expect.ExitCodeSuccess, nil, expect.All(
85 expect.Contains(dbImageName.Name()),
86 expect.DoesNotContain(wordpressImageName.Name()),
87 )),
88 },
89 {
90 Description: "images",
91 Command: func(data test.Data, helpers test.Helpers) test.TestableCommand {

Callers

nothing calls this directly

Calls 13

ParseFunction · 0.92
SetupFunction · 0.92
SaveMethod · 0.65
TempMethod · 0.65
SetMethod · 0.65
LabelsMethod · 0.65
PathMethod · 0.65
EnsureMethod · 0.65
AnyhowMethod · 0.65
CommandMethod · 0.65
GetMethod · 0.65
NameMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…