package host import ( "context" "os" "testing" "github.com/carlosframework/platform/internal/hostbox" execlease "github.com/carlosframework/platform/internal/hostexec" ) func TestPlan14RemoteUnlaunchedCleanup(t *testing.T) { for _, fault := range []string{"none", "legacy", "read-error", "local-inventory"} { t.Run(fault, func(t *testing.T) { f := newRecoveryFixture(t) launches, inventory := hostbox.RemoteJournals(func(ctx context.Context, q hostbox.JournalRequest) (hostbox.JournalResponse, error) { if q.Op != "has-host" { t.Fatalf("unexpected root operation %s", q.Op) } if fault == "read-error" { return hostbox.JournalResponse{}, os.ErrPermission } return hostbox.JournalResponse{V: 1, ID: q.ID}, nil }) if fault == "local-inventory" { inventory = nil } p := &productionClaimLocal{legacyParticipation: fault == "legacy", assembly: &ClaimAssembly{Wake: &ClaimWakeAssembly{}, Launches: launches, Reconcile: &hostbox.ReconcileAdapter{Inventory: inventory, Census: &hostbox.EmptyInstallationCensus{}}}} err := p.cleanup(t.Context(), f.read(), execlease.Binding{}) if (err == nil) != (fault == "none") { t.Fatal(fault, err) } }) } }