From fa55457fd6b7b4c8e7b169def2823e3ec493b727 Mon Sep 17 00:00:00 2001 From: Antonio Nesic Date: Tue, 3 Mar 2026 12:27:46 +0100 Subject: [PATCH] test: cover SetNextCursor marshal error branch --- page_info_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/page_info_test.go b/page_info_test.go index f61af2c..0e13546 100644 --- a/page_info_test.go +++ b/page_info_test.go @@ -2,6 +2,7 @@ package spindle import ( "fmt" + "math" "testing" ) @@ -216,6 +217,23 @@ func TestCursorValuesInvalidJSON(t *testing.T) { } } +func TestSetNextCursorMarshalError(t *testing.T) { + t.Parallel() + + p := &PageInfo{Limit: 10} + result := p.SetNextCursor(map[string]any{"bad": math.NaN()}) + + if result != p { + t.Error("SetNextCursor should return the same PageInfo on error") + } + if p.HasMore { + t.Error("HasMore should remain false on marshal error") + } + if p.NextCursor != "" { + t.Errorf("NextCursor = %q, want empty on marshal error", p.NextCursor) + } +} + func TestNextCursorURL(t *testing.T) { t.Parallel()