(t *testing.T)
| 14 | ) |
| 15 | |
| 16 | func TestGetLabel(t *testing.T) { |
| 17 | t.Parallel() |
| 18 | |
| 19 | // Verify tool definition |
| 20 | serverTool := GetLabel(translations.NullTranslationHelper) |
| 21 | tool := serverTool.Tool |
| 22 | require.NoError(t, toolsnaps.Test(tool.Name, tool)) |
| 23 | |
| 24 | assert.Equal(t, "get_label", tool.Name) |
| 25 | assert.NotEmpty(t, tool.Description) |
| 26 | assert.True(t, tool.Annotations.ReadOnlyHint, "get_label tool should be read-only") |
| 27 | |
| 28 | tests := []struct { |
| 29 | name string |
| 30 | requestArgs map[string]any |
| 31 | mockedClient *http.Client |
| 32 | expectToolError bool |
| 33 | expectedToolErrMsg string |
| 34 | }{ |
| 35 | { |
| 36 | name: "successful label retrieval", |
| 37 | requestArgs: map[string]any{ |
| 38 | "owner": "owner", |
| 39 | "repo": "repo", |
| 40 | "name": "bug", |
| 41 | }, |
| 42 | mockedClient: githubv4mock.NewMockedHTTPClient( |
| 43 | githubv4mock.NewQueryMatcher( |
| 44 | struct { |
| 45 | Repository struct { |
| 46 | Label struct { |
| 47 | ID githubv4.ID |
| 48 | Name githubv4.String |
| 49 | Color githubv4.String |
| 50 | Description githubv4.String |
| 51 | } `graphql:"label(name: $name)"` |
| 52 | } `graphql:"repository(owner: $owner, name: $repo)"` |
| 53 | }{}, |
| 54 | map[string]any{ |
| 55 | "owner": githubv4.String("owner"), |
| 56 | "repo": githubv4.String("repo"), |
| 57 | "name": githubv4.String("bug"), |
| 58 | }, |
| 59 | githubv4mock.DataResponse(map[string]any{ |
| 60 | "repository": map[string]any{ |
| 61 | "label": map[string]any{ |
| 62 | "id": githubv4.ID("test-label-id"), |
| 63 | "name": githubv4.String("bug"), |
| 64 | "color": githubv4.String("d73a4a"), |
| 65 | "description": githubv4.String("Something isn't working"), |
| 66 | }, |
| 67 | }, |
| 68 | }), |
| 69 | ), |
| 70 | ), |
| 71 | expectToolError: false, |
| 72 | }, |
| 73 | { |
nothing calls this directly
no test coverage detected