package stacks import ( "encoding/json" "strings" "testing" ) // R-489 — the removal reports the volumes it removed, and `[]` when none — never `null`. // // COMPANION RED-PROOF (REPORT.md): make removedVolumes return nil for an empty result — the JSON // reads null and the second assertion fails. func TestR489_RemovedVolumesIsADifferenceAndNeverNull(t *testing.T) { got := removedVolumes([]string{"app_data", "app_db", "app_cache"}, []string{"app_cache"}) if strings.Join(got, ",") != "app_data,app_db" { t.Errorf("before minus after = %v", got) } b, _ := json.Marshal(RemoveResponse{VolumesRemoved: removedVolumes(nil, nil)}) if !strings.Contains(string(b), `"volumes_removed":[]`) { t.Errorf("no volumes must read as [] — got %s", b) } } func TestR489_ProjectVolumesReadsTheDockerListing(t *testing.T) { m := &Manager{} var seen []string m.execFn = func(name string, args ...string) (string, error) { seen = append([]string{name}, args...) return "app_data\napp_db\n\n", nil } got := m.projectVolumes("app") if strings.Join(got, ",") != "app_data,app_db" { t.Errorf("volumes = %v", got) } if !strings.Contains(strings.Join(seen, " "), "label=com.docker.compose.project=app") { t.Errorf("must filter by the compose project label; ran %v", seen) } }