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

Function Test_RemoveSubIssue

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

Source from the content-addressed store, hash-verified

4358}
4359
4360func Test_RemoveSubIssue(t *testing.T) {
4361 // Verify tool definition once
4362 serverTool := SubIssueWrite(translations.NullTranslationHelper)
4363 tool := serverTool.Tool
4364 require.NoError(t, toolsnaps.Test(tool.Name, tool))
4365
4366 assert.Equal(t, "sub_issue_write", tool.Name)
4367 assert.NotEmpty(t, tool.Description)
4368 assert.Contains(t, tool.InputSchema.(*jsonschema.Schema).Properties, "method")
4369 assert.Contains(t, tool.InputSchema.(*jsonschema.Schema).Properties, "owner")
4370 assert.Contains(t, tool.InputSchema.(*jsonschema.Schema).Properties, "repo")
4371 assert.Contains(t, tool.InputSchema.(*jsonschema.Schema).Properties, "issue_number")
4372 assert.Contains(t, tool.InputSchema.(*jsonschema.Schema).Properties, "sub_issue_id")
4373 assert.ElementsMatch(t, tool.InputSchema.(*jsonschema.Schema).Required, []string{"method", "owner", "repo", "issue_number", "sub_issue_id"})
4374
4375 // Setup mock issue for success case (matches GitHub API response format - the updated parent issue)
4376 mockIssue := &github.Issue{
4377 Number: github.Ptr(42),
4378 Title: github.Ptr("Parent Issue"),
4379 Body: github.Ptr("This is the parent issue after sub-issue removal"),
4380 State: github.Ptr("open"),
4381 HTMLURL: github.Ptr("https://github.com/owner/repo/issues/42"),
4382 User: &github.User{
4383 Login: github.Ptr("testuser"),
4384 },
4385 Labels: []*github.Label{
4386 {
4387 Name: github.Ptr("enhancement"),
4388 Color: github.Ptr("84b6eb"),
4389 Description: github.Ptr("New feature or request"),
4390 },
4391 },
4392 }
4393
4394 tests := []struct {
4395 name string
4396 mockedClient *http.Client
4397 requestArgs map[string]any
4398 expectError bool
4399 expectedIssue *github.Issue
4400 expectedErrMsg string
4401 }{
4402 {
4403 name: "successful sub-issue removal",
4404 mockedClient: MockHTTPClientWithHandlers(map[string]http.HandlerFunc{
4405 DeleteReposIssuesSubIssueByOwnerByRepoByIssueNumber: mockResponse(t, http.StatusOK, mockIssue),
4406 }),
4407 requestArgs: map[string]any{
4408 "method": "remove",
4409 "owner": "owner",
4410 "repo": "repo",
4411 "issue_number": float64(42),
4412 "sub_issue_id": float64(123),
4413 },
4414 expectError: false,
4415 expectedIssue: mockIssue,
4416 },
4417 {

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