package stacks import ( "errors" "testing" ) // R-634 (v0.265.0) — the backstop for every caller: a stop or a start while the deploy's own // `compose up` is running is refused BEFORE any compose command. // // COMPANION RED-PROOF (REPORT.md): delete the Deploying check in StopStack — the stop falls through to // `compose down` and the error is no longer ErrStackDeploying. func TestR634_StopAndStartRefuseADeployingStack(t *testing.T) { m, _, _, _ := newSlice4Manager(t) // NEVER a real compose: the control below falls through to `compose down`, and the stack dir is // named like a real app. An empty PATH + the v1 binary name guarantees the exec cannot find // anything to run, on any machine this test runs on. m.composeCmd = "docker-compose" t.Setenv("PATH", t.TempDir()) m.mu.Lock() m.stacks["nextcloud"].Deploying = true m.mu.Unlock() if err := m.StopStack("nextcloud"); !errors.Is(err, ErrStackDeploying) { t.Fatalf("StopStack on a deploying stack = %v, want ErrStackDeploying", err) } if err := m.StartStack("nextcloud"); !errors.Is(err, ErrStackDeploying) { t.Fatalf("StartStack on a deploying stack = %v, want ErrStackDeploying", err) } // Control: once the deploy is over, the same calls are not refused for THIS reason. m.mu.Lock() m.stacks["nextcloud"].Deploying = false m.mu.Unlock() if err := m.StopStack("nextcloud"); errors.Is(err, ErrStackDeploying) { t.Fatal("control: a stack that is not deploying must not be refused as deploying") } }