package hostops import ( "context" "errors" "github.com/carlosframework/platform/internal/hostclaim" "github.com/carlosframework/platform/internal/park" "testing" ) func TestPlan13RemoteAdapterUsesBoundHome(t *testing.T) { f := newMoveStartFixture(t, nil) o := f.read(t) _, err := hostclaim.Update(t.Context(), f.raw, o, func(c *hostclaim.Claim) error { c.Obligations = []hostclaim.Obligation{{ID: "chore", Op: "old", Kind: "park-replica", Region: "@home", Owner: "region:@home", Retirement: "ret"}} return nil }) if err != nil { t.Fatal(err) } sentinel := errors.New("scope reached") for _, home := range []string{"ie", ""} { e := park.Engine{Claims: f.raw, Region: "ie", HomeRegion: home, Leases: plan13NoLeases{}, Authorize: func(context.Context, hostclaim.Observed, hostclaim.Obligation) error { return nil }, View: func(context.Context, hostclaim.Observed) (park.View, error) { return park.View{}, nil }} err := RunOwnedRemote(t.Context(), &e, park.Work{Host: f.host, ID: "chore", Op: "old"}, func(context.Context, hostclaim.Observed, hostclaim.Obligation) (hostclaim.ParkScope, error) { return hostclaim.ParkScope{}, sentinel }) if errors.Is(err, sentinel) != (home != "") { t.Fatal(home, err) } } } type plan13NoLeases struct{} func (plan13NoLeases) Acquire(context.Context, string, string) (park.HeldLease, error) { return nil, errors.New("unexpected lease") }