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)
| 33 | // binary's "stop" subcommand. The example provider writes a sentinel file at |
| 34 | // PROVIDER_STOP_MARKER when its stop subcommand runs. |
| 35 | func 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 | |
| 63 | func TestDependsOnMultipleProviders(t *testing.T) { |
| 64 | provider, err := findExecutable("example-provider") |
nothing calls this directly
no test coverage detected