package schedule import ( "context" "errors" "testing" "github.com/carlosframework/platform/internal/hostwrite" "github.com/carlosframework/platform/internal/registry" ) type timerDeny struct{} func (timerDeny) With(context.Context, hostwrite.Identity, func() error) error { return hostwrite.ErrUnavailable } func TestSelectedTimerRejectsRetiredProducer(t *testing.T) { // A nil underlying pointer would panic if a denied write reached the registry. var reg *registry.Registry store := SelectedTimers{Store: reg, Work: timerDeny{}, Context: context.Background(), Host: "shop.example"} if err := store.UpsertTimer(registry.Timer{Host: "shop.example"}); !errors.Is(err, hostwrite.ErrUnavailable) { t.Fatal(err) } if err := store.DeleteTimer("shop.example", "one"); !errors.Is(err, hostwrite.ErrUnavailable) { t.Fatal(err) } if err := store.DeleteTimer("other.example", "one"); !errors.Is(err, errTimerHost) { t.Fatal(err) } }