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

Function TestProjectVolumeBind

pkg/e2e/volumes_test.go:95–121  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

93}
94
95func TestProjectVolumeBind(t *testing.T) {
96 if composeStandaloneMode {
97 t.Skip()
98 }
99 c := NewParallelCLI(t)
100 const projectName = "compose-e2e-project-volume-bind"
101
102 t.Run("up on project volume with bind specification", func(t *testing.T) {
103 if runtime.GOOS == "windows" {
104 t.Skip("Running on Windows. Skipping...")
105 }
106 tmpDir := t.TempDir()
107
108 c.RunDockerComposeCmd(t, "--project-name", projectName, "down")
109
110 c.RunDockerOrExitError(t, "volume", "rm", "-f", projectName+"_project-data").Assert(t, icmd.Success)
111 cmd := c.NewCmdWithEnv([]string{"TEST_DIR=" + tmpDir},
112 "docker", "compose", "--project-directory", "fixtures/project-volume-bind-test", "--project-name", projectName, "up", "-d")
113 icmd.RunCmd(cmd).Assert(t, icmd.Success)
114 defer c.RunDockerComposeCmd(t, "--project-name", projectName, "down")
115
116 c.RunCmd(t, "sh", "-c", "echo SUCCESS > "+filepath.Join(tmpDir, "resultfile")).Assert(t, icmd.Success)
117
118 ret := c.RunDockerOrExitError(t, "exec", "frontend", "bash", "-c", "cat /data/resultfile").Assert(t, icmd.Success)
119 assert.Assert(t, strings.Contains(ret.Stdout(), "SUCCESS"))
120 })
121}
122
123func TestUpSwitchVolumes(t *testing.T) {
124 c := NewCLI(t)

Callers

nothing calls this directly

Calls 6

NewParallelCLIFunction · 0.85
TempDirMethod · 0.80
RunDockerComposeCmdMethod · 0.80
RunDockerOrExitErrorMethod · 0.80
NewCmdWithEnvMethod · 0.80
RunCmdMethod · 0.80

Tested by

no test coverage detected