(t *testing.T)
| 139 | } |
| 140 | |
| 141 | func TestListLabels(t *testing.T) { |
| 142 | t.Parallel() |
| 143 | |
| 144 | // Verify tool definition |
| 145 | serverTool := ListLabels(translations.NullTranslationHelper) |
| 146 | tool := serverTool.Tool |
| 147 | require.NoError(t, toolsnaps.Test(tool.Name, tool)) |
| 148 | |
| 149 | assert.Equal(t, "list_label", tool.Name) |
| 150 | assert.NotEmpty(t, tool.Description) |
| 151 | assert.True(t, tool.Annotations.ReadOnlyHint, "list_label tool should be read-only") |
| 152 | |
| 153 | tests := []struct { |
| 154 | name string |
| 155 | requestArgs map[string]any |
| 156 | mockedClient *http.Client |
| 157 | expectToolError bool |
| 158 | expectedToolErrMsg string |
| 159 | }{ |
| 160 | { |
| 161 | name: "successful repository labels listing", |
| 162 | requestArgs: map[string]any{ |
| 163 | "owner": "owner", |
| 164 | "repo": "repo", |
| 165 | }, |
| 166 | mockedClient: githubv4mock.NewMockedHTTPClient( |
| 167 | githubv4mock.NewQueryMatcher( |
| 168 | struct { |
| 169 | Repository struct { |
| 170 | Labels struct { |
| 171 | Nodes []struct { |
| 172 | ID githubv4.ID |
| 173 | Name githubv4.String |
| 174 | Color githubv4.String |
| 175 | Description githubv4.String |
| 176 | } |
| 177 | TotalCount githubv4.Int |
| 178 | } `graphql:"labels(first: 100)"` |
| 179 | } `graphql:"repository(owner: $owner, name: $repo)"` |
| 180 | }{}, |
| 181 | map[string]any{ |
| 182 | "owner": githubv4.String("owner"), |
| 183 | "repo": githubv4.String("repo"), |
| 184 | }, |
| 185 | githubv4mock.DataResponse(map[string]any{ |
| 186 | "repository": map[string]any{ |
| 187 | "labels": map[string]any{ |
| 188 | "nodes": []any{ |
| 189 | map[string]any{ |
| 190 | "id": githubv4.ID("label-1"), |
| 191 | "name": githubv4.String("bug"), |
| 192 | "color": githubv4.String("d73a4a"), |
| 193 | "description": githubv4.String("Something isn't working"), |
| 194 | }, |
| 195 | map[string]any{ |
| 196 | "id": githubv4.ID("label-2"), |
| 197 | "name": githubv4.String("enhancement"), |
| 198 | "color": githubv4.String("a2eeef"), |
nothing calls this directly
no test coverage detected