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

Function Test_UIGet

pkg/github/ui_tools_test.go:95–533  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

93}
94
95func Test_UIGet(t *testing.T) {
96 // Verify tool definition
97 serverTool := UIGet(translations.NullTranslationHelper)
98 tool := serverTool.Tool
99 require.NoError(t, toolsnaps.Test(tool.Name, tool))
100
101 assert.Equal(t, "ui_get", tool.Name)
102 assert.NotEmpty(t, tool.Description)
103 assert.Contains(t, tool.InputSchema.(*jsonschema.Schema).Properties, "method")
104 assert.Contains(t, tool.InputSchema.(*jsonschema.Schema).Properties, "owner")
105 assert.Contains(t, tool.InputSchema.(*jsonschema.Schema).Properties, "repo")
106 assert.ElementsMatch(t, tool.InputSchema.(*jsonschema.Schema).Required, []string{"method", "owner"})
107 assert.True(t, tool.Annotations.ReadOnlyHint, "ui_get should be read-only")
108 assert.Equal(t, MCPAppsFeatureFlag, serverTool.FeatureFlagEnable, "ui_get should be gated on the MCP Apps feature flag")
109
110 // ui_get must be app-only so the host hides it from the agent's tool list
111 // while keeping it callable by the views (MCP Apps 2026-01-26 spec).
112 ui, ok := tool.Meta["ui"].(map[string]any)
113 require.True(t, ok, "ui_get should declare _meta.ui")
114 assert.Equal(t, []string{"app"}, ui["visibility"], "ui_get should be app-only")
115
116 // Setup mock data
117 mockAssignees := []*github.User{
118 {Login: github.Ptr("user1"), AvatarURL: github.Ptr("https://avatars.githubusercontent.com/u/1")},
119 {Login: github.Ptr("user2"), AvatarURL: github.Ptr("https://avatars.githubusercontent.com/u/2")},
120 }
121
122 mockBranches := []*github.Branch{
123 {Name: github.Ptr("main"), Protected: github.Ptr(true)},
124 {Name: github.Ptr("feature"), Protected: github.Ptr(false)},
125 }
126
127 dueDate := time.Date(2026, 1, 31, 0, 0, 0, 0, time.UTC)
128 mockMilestones := []*github.Milestone{
129 {Number: github.Ptr(1), Title: github.Ptr("with due date"), DueOn: &github.Timestamp{Time: dueDate}},
130 {Number: github.Ptr(2), Title: github.Ptr("no due date")},
131 }
132
133 mockIssueTypes := []*github.IssueType{
134 {Name: github.Ptr("Bug")},
135 {Name: github.Ptr("Feature")},
136 }
137
138 mockReviewers := []*github.User{
139 {Login: github.Ptr("octocat"), AvatarURL: github.Ptr("https://avatars.githubusercontent.com/u/583231")},
140 {Login: github.Ptr("dependabot[bot]"), AvatarURL: github.Ptr("https://avatars.githubusercontent.com/in/29110")},
141 {Login: github.Ptr("github-actions"), Type: github.Ptr("Bot")},
142 }
143
144 mockReviewerTeams := []*github.Team{
145 {Slug: github.Ptr("docs"), Name: github.Ptr("Docs")},
146 }
147
148 tests := []struct {
149 name string
150 mockedClient *http.Client
151 mockedGQLClient *http.Client
152 requestArgs map[string]any

Callers

nothing calls this directly

Calls 15

TestFunction · 0.92
NewMockedHTTPClientFunction · 0.92
NewQueryMatcherFunction · 0.92
DataResponseFunction · 0.92
UIGetFunction · 0.85
mockResponseFunction · 0.85
alwaysNextPageHandlerFunction · 0.85
createMCPRequestFunction · 0.85
ContextWithDepsFunction · 0.85
getErrorResultFunction · 0.85

Tested by

no test coverage detected