MCPcopy
hub / github.com/github/github-mcp-server / Test_GetIssueLabels

Function Test_GetIssueLabels

pkg/github/issues_test.go:3416–3521  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

3414}
3415
3416func Test_GetIssueLabels(t *testing.T) {
3417 t.Parallel()
3418
3419 // Verify tool definition
3420 serverTool := IssueRead(translations.NullTranslationHelper)
3421 tool := serverTool.Tool
3422 require.NoError(t, toolsnaps.Test(tool.Name, tool))
3423
3424 assert.Equal(t, "issue_read", tool.Name)
3425 assert.NotEmpty(t, tool.Description)
3426 assert.Contains(t, tool.InputSchema.(*jsonschema.Schema).Properties, "method")
3427 assert.Contains(t, tool.InputSchema.(*jsonschema.Schema).Properties, "owner")
3428 assert.Contains(t, tool.InputSchema.(*jsonschema.Schema).Properties, "repo")
3429 assert.Contains(t, tool.InputSchema.(*jsonschema.Schema).Properties, "issue_number")
3430 assert.ElementsMatch(t, tool.InputSchema.(*jsonschema.Schema).Required, []string{"method", "owner", "repo", "issue_number"})
3431
3432 tests := []struct {
3433 name string
3434 requestArgs map[string]any
3435 mockedClient *http.Client
3436 expectToolError bool
3437 expectedToolErrMsg string
3438 }{
3439 {
3440 name: "successful issue labels listing",
3441 requestArgs: map[string]any{
3442 "method": "get_labels",
3443 "owner": "owner",
3444 "repo": "repo",
3445 "issue_number": float64(123),
3446 },
3447 mockedClient: githubv4mock.NewMockedHTTPClient(
3448 githubv4mock.NewQueryMatcher(
3449 struct {
3450 Repository struct {
3451 Issue struct {
3452 Labels struct {
3453 Nodes []struct {
3454 ID githubv4.ID
3455 Name githubv4.String
3456 Color githubv4.String
3457 Description githubv4.String
3458 }
3459 TotalCount githubv4.Int
3460 } `graphql:"labels(first: 100)"`
3461 } `graphql:"issue(number: $issueNumber)"`
3462 } `graphql:"repository(owner: $owner, name: $repo)"`
3463 }{},
3464 map[string]any{
3465 "owner": githubv4.String("owner"),
3466 "repo": githubv4.String("repo"),
3467 "issueNumber": githubv4.Int(123),
3468 },
3469 githubv4mock.DataResponse(map[string]any{
3470 "repository": map[string]any{
3471 "issue": map[string]any{
3472 "labels": map[string]any{
3473 "nodes": []any{

Callers

nothing calls this directly

Calls 13

TestFunction · 0.92
NewMockedHTTPClientFunction · 0.92
NewQueryMatcherFunction · 0.92
DataResponseFunction · 0.92
IssueReadFunction · 0.85
mustNewGHClientFunction · 0.85
stubRepoAccessCacheFunction · 0.85
stubFeatureFlagsFunction · 0.85
createMCPRequestFunction · 0.85
ContextWithDepsFunction · 0.85
getErrorResultFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected