Skip to content

Commit ac5bf32

Browse files
test: Refactor SortBy unmarshal test like #4323
Use the testJSONUnmarshalOnly helper for the success case of TestProjectV2ViewSortBy_UnmarshalJSON instead of unmarshaling by hand and asserting field by field, matching the style introduced in #4323. The error-case subtests stay manual since the helper expects a successful unmarshal.
1 parent 10bea9e commit ac5bf32

1 file changed

Lines changed: 4 additions & 12 deletions

File tree

github/projects_test.go

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1753,19 +1753,11 @@ func TestProjectV2ViewSortBy_UnmarshalJSON(t *testing.T) {
17531753
t.Parallel()
17541754
// The second element uses a string field_id, which the OpenAPI schema
17551755
// permits. The first exceeds 2^53 to confirm int64 (not float64) decoding.
1756-
var got []*ProjectV2ViewSortBy
1757-
if err := json.Unmarshal([]byte(`[[9007199254740993,"asc"],["456","desc"]]`), &got); err != nil {
1758-
t.Fatalf("Unmarshal returned error: %v", err)
1759-
}
1760-
if len(got) != 2 {
1761-
t.Fatalf("len(got) = %d, want 2", len(got))
1762-
}
1763-
if got[0].GetFieldID() != 9007199254740993 || got[0].GetDirection() != "asc" {
1764-
t.Errorf("got[0] = %+v, want {9007199254740993 asc}", got[0])
1765-
}
1766-
if got[1].GetFieldID() != 456 || got[1].GetDirection() != "desc" {
1767-
t.Errorf("got[1] = %+v, want {456 desc}", got[1])
1756+
want := []*ProjectV2ViewSortBy{
1757+
{FieldID: Ptr(int64(9007199254740993)), Direction: Ptr("asc")},
1758+
{FieldID: Ptr(int64(456)), Direction: Ptr("desc")},
17681759
}
1760+
testJSONUnmarshalOnly(t, want, `[[9007199254740993,"asc"],["456","desc"]]`)
17691761
})
17701762

17711763
t.Run("wrong tuple length is an error", func(t *testing.T) {

0 commit comments

Comments
 (0)