A fill aimed entirely outside its object is an error, and the test says so
Build image / build-and-push (push) Successful in 5s
Build image / build-and-push (push) Successful in 5s
TestFillRegionOutsideObjectPlantsNothing pinned the old silent success; the #127 review asked for the error, and the agent is the caller it helps. Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
@@ -212,10 +212,13 @@ func TestFillRegionRejectsNonFiniteRegion(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestFillRegionOutsideObjectPlantsNothing covers a region that misses the object
|
// TestFillRegionOutsideObjectIsRefused covers a region that misses the object
|
||||||
// entirely. clampTo inverts such a region rather than emptying it, and an
|
// entirely. clampTo inverts such a region rather than emptying it; it used to
|
||||||
// inverted region must plant nothing — not one plop at some point off the bed.
|
// plant nothing and report success, which read as "done" to a caller that had
|
||||||
func TestFillRegionOutsideObjectPlantsNothing(t *testing.T) {
|
// aimed at the wrong coordinates — the agent, mixing up the garden frame and
|
||||||
|
// the bed's local one. Now it is an error, and still never one plop at some
|
||||||
|
// point off the bed.
|
||||||
|
func TestFillRegionOutsideObjectIsRefused(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
s := newTestService(t, openConfig())
|
s := newTestService(t, openConfig())
|
||||||
owner := seedUser(t, s, "[email protected]")
|
owner := seedUser(t, s, "[email protected]")
|
||||||
@@ -225,12 +228,15 @@ func TestFillRegionOutsideObjectPlantsNothing(t *testing.T) {
|
|||||||
|
|
||||||
// Wholly east of the bed: clampTo gives MinX=500, MaxX=50.
|
// Wholly east of the bed: clampTo gives MinX=500, MaxX=50.
|
||||||
created, err := s.FillRegion(ctx, owner, bed.ID, rect(500, -50, 600, 50), plant.ID, nil, FillClump, nil)
|
created, err := s.FillRegion(ctx, owner, bed.ID, rect(500, -50, 600, 50), plant.ID, nil, FillClump, nil)
|
||||||
if err != nil {
|
if !errors.Is(err, domain.ErrInvalidInput) {
|
||||||
t.Fatalf("FillRegion: %v", err)
|
t.Errorf("FillRegion outside the bed: err = %v, want ErrInvalidInput", err)
|
||||||
}
|
}
|
||||||
if len(created) != 0 {
|
if len(created) != 0 {
|
||||||
t.Errorf("filled %d plops for a region outside the bed, want 0: %+v", len(created), created)
|
t.Errorf("filled %d plops for a region outside the bed, want 0: %+v", len(created), created)
|
||||||
}
|
}
|
||||||
|
if full, _ := s.GardenFull(ctx, owner, g.ID, nil); len(full.Plantings) != 0 {
|
||||||
|
t.Errorf("the bed holds %d plops after a refused fill", len(full.Plantings))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// seedFillBed makes a plantable bed of the given size centered in a big garden.
|
// seedFillBed makes a plantable bed of the given size centered in a big garden.
|
||||||
|
|||||||
Reference in New Issue
Block a user