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

Function TestWatchExec

pkg/e2e/watch_test.go:288–323  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

286}
287
288func TestWatchExec(t *testing.T) {
289 c := NewCLI(t)
290 const projectName = "test_watch_exec"
291
292 defer c.cleanupWithDown(t, projectName)
293
294 tmpdir := t.TempDir()
295 composeFilePath := filepath.Join(tmpdir, "compose.yaml")
296 CopyFile(t, filepath.Join("fixtures", "watch", "exec.yaml"), composeFilePath)
297 cmd := c.NewDockerComposeCmd(t, "-p", projectName, "-f", composeFilePath, "up", "--watch")
298 buffer := bytes.NewBuffer(nil)
299 cmd.Stdout = buffer
300 watch := icmd.StartCmd(cmd)
301
302 poll.WaitOn(t, func(l poll.LogT) poll.Result {
303 out := buffer.String()
304 if strings.Contains(out, "64 bytes from") {
305 return poll.Success()
306 }
307 return poll.Continue("%v", watch.Stdout())
308 })
309
310 t.Logf("Create new file")
311
312 testFile := filepath.Join(tmpdir, "test")
313 assert.NilError(t, os.WriteFile(testFile, []byte("test\n"), 0o600))
314
315 poll.WaitOn(t, func(l poll.LogT) poll.Result {
316 out := buffer.String()
317 if strings.Contains(out, "SUCCESS") {
318 return poll.Success()
319 }
320 return poll.Continue("%v", out)
321 })
322 c.RunDockerComposeCmdNoCheck(t, "-p", projectName, "kill", "-s", "9")
323}
324
325func TestWatchMultiServices(t *testing.T) {
326 c := NewCLI(t)

Callers

nothing calls this directly

Calls 8

cleanupWithDownMethod · 0.95
NewDockerComposeCmdMethod · 0.95
NewCLIFunction · 0.85
CopyFileFunction · 0.85
TempDirMethod · 0.80
WriteFileMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected