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

Function Test_ListIssueFields

pkg/github/issue_fields_test.go:17–308  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

15)
16
17func Test_ListIssueFields(t *testing.T) {
18 // Verify tool definition
19 serverTool := ListIssueFields(translations.NullTranslationHelper)
20 tool := serverTool.Tool
21 require.NoError(t, toolsnaps.Test(tool.Name, tool))
22
23 assert.Equal(t, "list_issue_fields", tool.Name)
24 assert.NotEmpty(t, tool.Description)
25 assert.True(t, tool.Annotations.ReadOnlyHint)
26 assert.Contains(t, tool.InputSchema.(*jsonschema.Schema).Properties, "owner")
27 assert.Contains(t, tool.InputSchema.(*jsonschema.Schema).Properties, "repo")
28 assert.ElementsMatch(t, tool.InputSchema.(*jsonschema.Schema).Required, []string{"owner"})
29 assert.ElementsMatch(t, serverTool.RequiredScopes, []string{"repo", "read:org"})
30 assert.ElementsMatch(t, serverTool.AcceptedScopes, []string{"repo", "read:org", "write:org", "admin:org"})
31
32 queryStruct := issueFieldsRepoQuery{}
33 defaultVars := map[string]any{
34 "owner": githubv4.String("testowner"),
35 "name": githubv4.String("testrepo"),
36 }
37 orgQueryStruct := issueFieldsOrgQuery{}
38 defaultOrgVars := map[string]any{
39 "login": githubv4.String("testowner"),
40 }
41
42 tests := []struct {
43 name string
44 requestArgs map[string]any
45 mockQueryStruct any
46 mockVars map[string]any
47 gqlResponse githubv4mock.GQLResponse
48 expectError bool
49 expectedFields []IssueField
50 expectedErrMsg string
51 }{
52 {
53 name: "no fields returns empty list",
54 requestArgs: map[string]any{
55 "owner": "testowner",
56 "repo": "testrepo",
57 },
58 gqlResponse: githubv4mock.DataResponse(map[string]any{
59 "repository": map[string]any{
60 "issueFields": map[string]any{
61 "nodes": []any{},
62 },
63 },
64 }),
65 expectedFields: []IssueField{},
66 },
67 {
68 name: "text field returned",
69 requestArgs: map[string]any{
70 "owner": "testowner",
71 "repo": "testrepo",
72 },
73 gqlResponse: githubv4mock.DataResponse(map[string]any{
74 "repository": map[string]any{

Callers

nothing calls this directly

Calls 13

TestFunction · 0.92
DataResponseFunction · 0.92
ErrorResponseFunction · 0.92
NewMockedHTTPClientFunction · 0.92
NewQueryMatcherFunction · 0.92
ListIssueFieldsFunction · 0.85
createMCPRequestFunction · 0.85
ContextWithDepsFunction · 0.85
getErrorResultFunction · 0.85
getTextResultFunction · 0.85
StringMethod · 0.45
HandlerMethod · 0.45

Tested by

no test coverage detected