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

Function Test_AddSubIssue

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

Source from the content-addressed store, hash-verified

3643}
3644
3645func Test_AddSubIssue(t *testing.T) {
3646 // Verify tool definition once
3647 serverTool := SubIssueWrite(translations.NullTranslationHelper)
3648 tool := serverTool.Tool
3649 require.NoError(t, toolsnaps.Test(tool.Name, tool))
3650
3651 assert.Equal(t, "sub_issue_write", tool.Name)
3652 assert.NotEmpty(t, tool.Description)
3653 assert.Contains(t, tool.InputSchema.(*jsonschema.Schema).Properties, "method")
3654 assert.Contains(t, tool.InputSchema.(*jsonschema.Schema).Properties, "owner")
3655 assert.Contains(t, tool.InputSchema.(*jsonschema.Schema).Properties, "repo")
3656 assert.Contains(t, tool.InputSchema.(*jsonschema.Schema).Properties, "issue_number")
3657 assert.Contains(t, tool.InputSchema.(*jsonschema.Schema).Properties, "sub_issue_id")
3658 assert.Contains(t, tool.InputSchema.(*jsonschema.Schema).Properties, "replace_parent")
3659 assert.ElementsMatch(t, tool.InputSchema.(*jsonschema.Schema).Required, []string{"method", "owner", "repo", "issue_number", "sub_issue_id"})
3660
3661 // Setup mock issue for success case (matches GitHub API response format)
3662 mockIssue := &github.Issue{
3663 Number: github.Ptr(42),
3664 Title: github.Ptr("Parent Issue"),
3665 Body: github.Ptr("This is the parent issue with a sub-issue"),
3666 State: github.Ptr("open"),
3667 HTMLURL: github.Ptr("https://github.com/owner/repo/issues/42"),
3668 User: &github.User{
3669 Login: github.Ptr("testuser"),
3670 },
3671 Labels: []*github.Label{
3672 {
3673 Name: github.Ptr("enhancement"),
3674 Color: github.Ptr("84b6eb"),
3675 Description: github.Ptr("New feature or request"),
3676 },
3677 },
3678 }
3679
3680 tests := []struct {
3681 name string
3682 mockedClient *http.Client
3683 requestArgs map[string]any
3684 expectError bool
3685 expectedIssue *github.Issue
3686 expectedErrMsg string
3687 }{
3688 {
3689 name: "successful sub-issue addition with all parameters",
3690 mockedClient: MockHTTPClientWithHandlers(map[string]http.HandlerFunc{
3691 PostReposIssuesSubIssuesByOwnerByRepoByIssueNumber: mockResponse(t, http.StatusCreated, mockIssue),
3692 }),
3693 requestArgs: map[string]any{
3694 "method": "add",
3695 "owner": "owner",
3696 "repo": "repo",
3697 "issue_number": float64(42),
3698 "sub_issue_id": float64(123),
3699 "replace_parent": true,
3700 },
3701 expectError: false,
3702 expectedIssue: mockIssue,

Callers

nothing calls this directly

Calls 10

TestFunction · 0.92
SubIssueWriteFunction · 0.85
mockResponseFunction · 0.85
mustNewGHClientFunction · 0.85
createMCPRequestFunction · 0.85
ContextWithDepsFunction · 0.85
getTextResultFunction · 0.85
HandlerMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected