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

Function TestListLabels

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

Source from the content-addressed store, hash-verified

139}
140
141func 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"),

Callers

nothing calls this directly

Calls 10

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

Tested by

no test coverage detected