Harden host deletion and test stability

This commit is contained in:
phamnazage-jpg
2026-05-25 07:30:07 +08:00
parent 916569ccc5
commit 5e76fb20d0
12 changed files with 240 additions and 61 deletions

View File

@@ -1545,11 +1545,13 @@ func TestActionSetHostClosuresAndAccessPreview(t *testing.T) {
t.Fatalf("AccessPreview(subscription) = %+v, want available=false", preview)
}
if err := actions.DeleteHost(context.Background(), "host-main"); err != nil {
t.Fatalf("DeleteHost() error = %v", err)
}
if _, err := store.Hosts().GetByHostID(context.Background(), "host-main"); err == nil {
t.Fatal("DeleteHost() did not remove host-main")
if err := actions.DeleteHost(context.Background(), "host-main"); err == nil {
t.Fatal("DeleteHost() error = nil, want host_in_use conflict")
} else {
httpErr, ok := err.(*httpError)
if !ok || httpErr.StatusCode != http.StatusConflict || httpErr.Code != "host_in_use" {
t.Fatalf("DeleteHost() error = %T %v, want *httpError host_in_use conflict", err, err)
}
}
}