From ac9f6e8c630fe9f1b061dd24c295f9fc82f9e22b Mon Sep 17 00:00:00 2001 From: Steve Dudenhoeffer Date: Sun, 23 Aug 2026 00:28:44 -0400 Subject: [PATCH] A fill aimed entirely outside its object is an error, and the test says so 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 --- internal/service/ops_test.go | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/internal/service/ops_test.go b/internal/service/ops_test.go index 2599277..2787ae0 100644 --- a/internal/service/ops_test.go +++ b/internal/service/ops_test.go @@ -212,10 +212,13 @@ func TestFillRegionRejectsNonFiniteRegion(t *testing.T) { } } -// TestFillRegionOutsideObjectPlantsNothing covers a region that misses the object -// entirely. clampTo inverts such a region rather than emptying it, and an -// inverted region must plant nothing — not one plop at some point off the bed. -func TestFillRegionOutsideObjectPlantsNothing(t *testing.T) { +// TestFillRegionOutsideObjectIsRefused covers a region that misses the object +// entirely. clampTo inverts such a region rather than emptying it; it used to +// plant nothing and report success, which read as "done" to a caller that had +// 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() s := newTestService(t, openConfig()) owner := seedUser(t, s, "a@example.com") @@ -225,12 +228,15 @@ func TestFillRegionOutsideObjectPlantsNothing(t *testing.T) { // 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) - if err != nil { - t.Fatalf("FillRegion: %v", err) + if !errors.Is(err, domain.ErrInvalidInput) { + t.Errorf("FillRegion outside the bed: err = %v, want ErrInvalidInput", err) } if len(created) != 0 { 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.