package host import ( "context" "errors" "github.com/carlosframework/platform/internal/hostclaim" "testing" ) func TestPlan12LocalParkUsesOwnerAndRechecksIdentity(t *testing.T) { identityErr := error(nil) calls := 0 sentinel := errors.New("owner") local := claimMoveLocalAuthorizer(func(context.Context) error { return identityErr }, func(_ context.Context, o hostclaim.Observed, ob hostclaim.Obligation) error { calls++ if o.Host != "app.example" || ob.Park != nil || ob.Kind != "park-local" { t.Fatal("wrong owner input") } return sentinel }) c := &hostclaim.Claim{Host: "app.example"} ob := hostclaim.Obligation{Kind: "park-local"} if err := local(t.Context(), c, ob); !errors.Is(err, sentinel) || calls != 1 { t.Fatal(err, calls) } identityErr = errors.New("enrollment changed") if err := local(t.Context(), c, ob); !errors.Is(err, identityErr) || calls != 1 { t.Fatal(err, calls) } }