MCPcopy Index your code
hub / github.com/github/github-mcp-server / TestGetLabel

Function TestGetLabel

pkg/github/labels_test.go:16–139  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

14)
15
16func 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 {

Callers

nothing calls this directly

Calls 10

TestFunction · 0.92
NewMockedHTTPClientFunction · 0.92
NewQueryMatcherFunction · 0.92
DataResponseFunction · 0.92
GetLabelFunction · 0.85
createMCPRequestFunction · 0.85
ContextWithDepsFunction · 0.85
getErrorResultFunction · 0.85
StringMethod · 0.45
HandlerMethod · 0.45

Tested by

no test coverage detected