package hostclaim import ( "context" "fmt" "testing" "time" "github.com/carlosframework/platform/internal/release" ) func TestSingleOwnerAdoptionDiscoveryBoundary(t *testing.T) { for _, extraRegion := range []bool{false, true} { t.Run(fmt.Sprint(extraRegion), func(t *testing.T) { store := release.NewDirStore(t.TempDir()) host := "single.example" nh := NewHolder{Family: "instance", Key: "apps/acct/app/instances/" + host + ".json", Account: "acct", App: "app", Host: host, CreatedAt: time.Date(2026, 10, 7, 0, 0, 0, 0, time.UTC), Region: "ie"} var otherRegions []string if extraRegion { otherRegions = []string{"us"} } seq := 0 obs, err := Update(context.Background(), store, Observed{Host: host, Absent: true}, Adopt(nh, "only-box", otherRegions, nil, "discovery", func() string { seq++; return fmt.Sprintf("id%d", seq) })) if err != nil { t.Fatal(err) } if !extraRegion { if !obs.Claim.Touched.Complete || len(obs.Claim.Obligations) != 0 || obs.Claim.Touched.DiscoveryOp != "" { t.Fatalf("single-region adoption needs no evidence: %+v", obs.Claim) } } else { if obs.Claim.Touched.Complete || len(obs.Claim.Obligations) != 1 || obs.Claim.Obligations[0].Region != "us" { t.Fatalf("retirement region was omitted: %+v", obs.Claim) } } }) } }