From 4d166a652daf98021f04edaed427516cf7953a60 Mon Sep 17 00:00:00 2001 From: SAY-5 Date: Mon, 11 May 2026 19:18:05 -0700 Subject: [PATCH] fix: correct swapped JSON tags on PaginationLinks Prev/Next fields Signed-off-by: SAY-5 --- internal/entities/pagination.go | 4 ++-- internal/entities/pagination_test.go | 34 ++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 internal/entities/pagination_test.go diff --git a/internal/entities/pagination.go b/internal/entities/pagination.go index bfa7b3bb8..d8d63ae04 100644 --- a/internal/entities/pagination.go +++ b/internal/entities/pagination.go @@ -2,8 +2,8 @@ package entities type PaginationLinks struct { Self string `json:"self"` - Prev string `json:"next"` - Next string `json:"prev"` + Prev string `json:"prev"` + Next string `json:"next"` } type Pagination struct { diff --git a/internal/entities/pagination_test.go b/internal/entities/pagination_test.go new file mode 100644 index 000000000..c1a263ee8 --- /dev/null +++ b/internal/entities/pagination_test.go @@ -0,0 +1,34 @@ +package entities + +import ( + "encoding/json" + "testing" +) + +func TestPaginationLinks_JSONTagsMatchFieldNames(t *testing.T) { + links := PaginationLinks{ + Self: "self-url", + Prev: "prev-url", + Next: "next-url", + } + + raw, err := json.Marshal(links) + if err != nil { + t.Fatalf("marshal: %v", err) + } + + var decoded map[string]string + if err := json.Unmarshal(raw, &decoded); err != nil { + t.Fatalf("unmarshal: %v", err) + } + + if got := decoded["prev"]; got != "prev-url" { + t.Errorf(`json key "prev" = %q, want "prev-url"`, got) + } + if got := decoded["next"]; got != "next-url" { + t.Errorf(`json key "next" = %q, want "next-url"`, got) + } + if got := decoded["self"]; got != "self-url" { + t.Errorf(`json key "self" = %q, want "self-url"`, got) + } +}