Skip to content

Commit fd9f592

Browse files
committed
made tests consistent with other tests
1 parent 3e1bad4 commit fd9f592

File tree

1 file changed

+17
-23
lines changed

1 file changed

+17
-23
lines changed

pkg/github/discussions_test.go

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -702,12 +702,13 @@ func Test_ListDiscussionCategories(t *testing.T) {
702702
})
703703

704704
tests := []struct {
705-
name string
706-
reqParams map[string]interface{}
707-
vars map[string]interface{}
708-
mockResponse githubv4mock.GQLResponse
709-
expectError bool
710-
expectedCount int
705+
name string
706+
reqParams map[string]interface{}
707+
vars map[string]interface{}
708+
mockResponse githubv4mock.GQLResponse
709+
expectError bool
710+
expectedCount int
711+
expectedCategories []map[string]string
711712
}{
712713
{
713714
name: "list repository-level discussion categories",
@@ -719,6 +720,10 @@ func Test_ListDiscussionCategories(t *testing.T) {
719720
mockResponse: mockRespRepo,
720721
expectError: false,
721722
expectedCount: 2,
723+
expectedCategories: []map[string]string{
724+
{"id": "123", "name": "CategoryOne"},
725+
{"id": "456", "name": "CategoryTwo"},
726+
},
722727
},
723728
{
724729
name: "list org-level discussion categories (no repo provided)",
@@ -730,6 +735,11 @@ func Test_ListDiscussionCategories(t *testing.T) {
730735
mockResponse: mockRespOrg,
731736
expectError: false,
732737
expectedCount: 3,
738+
expectedCategories: []map[string]string{
739+
{"id": "789", "name": "Announcements"},
740+
{"id": "101", "name": "General"},
741+
{"id": "112", "name": "Ideas"},
742+
},
733743
},
734744
}
735745

@@ -762,23 +772,7 @@ func Test_ListDiscussionCategories(t *testing.T) {
762772
TotalCount int `json:"totalCount"`
763773
}
764774
require.NoError(t, json.Unmarshal([]byte(text), &response))
765-
assert.Len(t, response.Categories, tc.expectedCount)
766-
767-
// Verify specific content based on test case
768-
switch tc.name {
769-
case "list repository-level discussion categories":
770-
assert.Equal(t, "123", response.Categories[0]["id"])
771-
assert.Equal(t, "CategoryOne", response.Categories[0]["name"])
772-
assert.Equal(t, "456", response.Categories[1]["id"])
773-
assert.Equal(t, "CategoryTwo", response.Categories[1]["name"])
774-
case "list org-level discussion categories (no repo provided)":
775-
assert.Equal(t, "789", response.Categories[0]["id"])
776-
assert.Equal(t, "Announcements", response.Categories[0]["name"])
777-
assert.Equal(t, "101", response.Categories[1]["id"])
778-
assert.Equal(t, "General", response.Categories[1]["name"])
779-
assert.Equal(t, "112", response.Categories[2]["id"])
780-
assert.Equal(t, "Ideas", response.Categories[2]["name"])
781-
}
775+
assert.Equal(t, tc.expectedCategories, response.Categories)
782776
})
783777
}
784778
}

0 commit comments

Comments
 (0)