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

Function TestProviderStopHook

pkg/e2e/providers_test.go:35–61  ·  pkg/e2e/providers_test.go::TestProviderStopHook

TestProviderStopHook verifies that "docker compose stop" invokes the provider binary's "stop" subcommand. The example provider writes a sentinel file at PROVIDER_STOP_MARKER when its stop subcommand runs.

(t *testing.T)

Source from the content-addressed store, hash-verified

33// binary's "stop" subcommand. The example provider writes a sentinel file at
34// PROVIDER_STOP_MARKER when its stop subcommand runs.
35func TestProviderStopHook(t *testing.T) {
36 provider, err := findExecutable("example-provider")
37 assert.NilError(t, err)
38
39 markerFile := filepath.Join(t.TempDir(), "example-provider-stop-marker")
40
41 path := fmt.Sprintf("%s%s%s", os.Getenv("PATH"), string(os.PathListSeparator), filepath.Dir(provider))
42 c := NewParallelCLI(t, WithEnv(
43 "PATH="+path,
44 "PROVIDER_STOP_MARKER="+markerFile,
45 ))
46 const projectName = "provider-stop-hook"
47
48 t.Cleanup(func() {
49 _ = os.Remove(markerFile)
50 c.cleanupWithDown(t, projectName)
51 })
52
53 res := c.RunDockerComposeCmd(t, "-f", "fixtures/providers/provider-stop.yaml", "--project-name", projectName, "up", "-d")
54 res.Assert(t, icmd.Success)
55
56 res = c.RunDockerComposeCmd(t, "-f", "fixtures/providers/provider-stop.yaml", "--project-name", projectName, "stop")
57 res.Assert(t, icmd.Success)
58
59 _, statErr := os.Stat(markerFile)
60 assert.NilError(t, statErr, "expected example-provider stop subcommand to write marker file %q", markerFile)
61}
62
63func TestDependsOnMultipleProviders(t *testing.T) {
64 provider, err := findExecutable("example-provider")

Callers

nothing calls this directly

Calls 8

findExecutableFunction · 0.85
NewParallelCLIFunction · 0.85
WithEnvFunction · 0.85
TempDirMethod · 0.80
cleanupWithDownMethod · 0.80
RunDockerComposeCmdMethod · 0.80
RemoveMethod · 0.65
DirMethod · 0.45

Tested by

no test coverage detected