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

Function TestComposePs

cmd/nerdctl/compose/compose_ps_linux_test.go:38–172  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

36)
37
38func TestComposePs(t *testing.T) {
39 testCase := nerdtest.Setup()
40
41 testCase.Require = nerdtest.Private
42
43 var dockerComposeYAML = fmt.Sprintf(`
44services:
45 wordpress:
46 image: %s
47 container_name: wordpress_container
48 environment:
49 WORDPRESS_DB_HOST: db
50 WORDPRESS_DB_USER: exampleuser
51 WORDPRESS_DB_PASSWORD: examplepass
52 WORDPRESS_DB_NAME: exampledb
53 volumes:
54 - wordpress:/var/www/html
55 db:
56 image: %s
57 container_name: db_container
58 environment:
59 MYSQL_DATABASE: exampledb
60 MYSQL_USER: exampleuser
61 MYSQL_PASSWORD: examplepass
62 MYSQL_RANDOM_ROOT_PASSWORD: '1'
63 volumes:
64 - db:/var/lib/mysql
65 alpine:
66 image: %s
67 container_name: alpine_container
68
69volumes:
70 wordpress:
71 db:
72`, testutil.WordpressImage, testutil.MariaDBImage, testutil.CommonImage)
73
74 testCase.Setup = func(data test.Data, helpers test.Helpers) {
75 composePath := data.Temp().Save(dockerComposeYAML, "compose.yaml")
76 data.Labels().Set("composeYAML", composePath)
77
78 projectName := filepath.Base(filepath.Dir(composePath))
79 t.Logf("projectName=%q", projectName)
80
81 helpers.Ensure("compose", "-f", composePath, "up", "-d")
82
83 nerdtest.EnsureContainerStarted(helpers, "wordpress_container")
84 nerdtest.EnsureContainerStarted(helpers, "db_container")
85 }
86
87 testCase.Cleanup = func(data test.Data, helpers test.Helpers) {
88 if path := data.Labels().Get("composeYAML"); path != "" {
89 helpers.Anyhow("compose", "-f", path, "down", "-v")
90 }
91 }
92
93 assertHandler := func(expectedName, expectedImage string) test.Comparator {
94 return func(stdout string, t tig.T) {
95

Callers

nothing calls this directly

Calls 15

SetupFunction · 0.92
EnsureContainerStartedFunction · 0.92
NewReaderFunction · 0.92
AssertMethod · 0.80
ParseHeaderMethod · 0.80
ReadRowMethod · 0.80
SaveMethod · 0.65
TempMethod · 0.65
SetMethod · 0.65
LabelsMethod · 0.65
DirMethod · 0.65
EnsureMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…