From 81f8c924dc2639889380a111e485463790c6161d Mon Sep 17 00:00:00 2001 From: Harikesh Prajapati Date: Wed, 26 Oct 2022 18:17:27 +0530 Subject: [PATCH] Added test for resource JSON marshalling label search result --- github/search_test.go | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/github/search_test.go b/github/search_test.go index 0d49b36c19..c69c490445 100644 --- a/github/search_test.go +++ b/github/search_test.go @@ -876,3 +876,41 @@ func TestIssuesSearchResult_Marshal(t *testing.T) { testJSONMarshal(t, u, want) } + +func TestLabelsSearchResult_Marshal(t *testing.T) { + testJSONMarshal(t, &LabelsSearchResult{}, "{}") + + u := &LabelsSearchResult{ + Total: Int(5), + IncompleteResults: Bool(false), + Labels: []*LabelResult{ + { + ID: Int64(1), + URL: String("https://www.test-url.com"), + Name: String("test name"), + Color: String("green"), + Default: Bool(true), + Description: String("testDescription"), + Score: Float64(1), + }, + }, + } + + want := `{ + "total_count": 5, + "incomplete_results": false, + "items": [ + { + "id": 1, + "url": "https://www.test-url.com", + "name": "test name", + "color": "green", + "default": true, + "description": "testDescription", + "score": 1 + } + ] + }` + + testJSONMarshal(t, u, want) +}