@@ -702,12 +702,13 @@ func Test_ListDiscussionCategories(t *testing.T) {
702
702
})
703
703
704
704
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
711
712
}{
712
713
{
713
714
name : "list repository-level discussion categories" ,
@@ -719,6 +720,10 @@ func Test_ListDiscussionCategories(t *testing.T) {
719
720
mockResponse : mockRespRepo ,
720
721
expectError : false ,
721
722
expectedCount : 2 ,
723
+ expectedCategories : []map [string ]string {
724
+ {"id" : "123" , "name" : "CategoryOne" },
725
+ {"id" : "456" , "name" : "CategoryTwo" },
726
+ },
722
727
},
723
728
{
724
729
name : "list org-level discussion categories (no repo provided)" ,
@@ -730,6 +735,11 @@ func Test_ListDiscussionCategories(t *testing.T) {
730
735
mockResponse : mockRespOrg ,
731
736
expectError : false ,
732
737
expectedCount : 3 ,
738
+ expectedCategories : []map [string ]string {
739
+ {"id" : "789" , "name" : "Announcements" },
740
+ {"id" : "101" , "name" : "General" },
741
+ {"id" : "112" , "name" : "Ideas" },
742
+ },
733
743
},
734
744
}
735
745
@@ -762,23 +772,7 @@ func Test_ListDiscussionCategories(t *testing.T) {
762
772
TotalCount int `json:"totalCount"`
763
773
}
764
774
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 )
782
776
})
783
777
}
784
778
}
0 commit comments