(t *testing.T)
| 4358 | } |
| 4359 | |
| 4360 | func 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 | { |
nothing calls this directly
no test coverage detected