(t *testing.T)
| 4564 | } |
| 4565 | |
| 4566 | func Test_ReprioritizeSubIssue(t *testing.T) { |
| 4567 | // Verify tool definition once |
| 4568 | serverTool := SubIssueWrite(translations.NullTranslationHelper) |
| 4569 | tool := serverTool.Tool |
| 4570 | require.NoError(t, toolsnaps.Test(tool.Name, tool)) |
| 4571 | |
| 4572 | assert.Equal(t, "sub_issue_write", tool.Name) |
| 4573 | assert.NotEmpty(t, tool.Description) |
| 4574 | assert.Contains(t, tool.InputSchema.(*jsonschema.Schema).Properties, "method") |
| 4575 | assert.Contains(t, tool.InputSchema.(*jsonschema.Schema).Properties, "owner") |
| 4576 | assert.Contains(t, tool.InputSchema.(*jsonschema.Schema).Properties, "repo") |
| 4577 | assert.Contains(t, tool.InputSchema.(*jsonschema.Schema).Properties, "issue_number") |
| 4578 | assert.Contains(t, tool.InputSchema.(*jsonschema.Schema).Properties, "sub_issue_id") |
| 4579 | assert.Contains(t, tool.InputSchema.(*jsonschema.Schema).Properties, "after_id") |
| 4580 | assert.Contains(t, tool.InputSchema.(*jsonschema.Schema).Properties, "before_id") |
| 4581 | assert.ElementsMatch(t, tool.InputSchema.(*jsonschema.Schema).Required, []string{"method", "owner", "repo", "issue_number", "sub_issue_id"}) |
| 4582 | |
| 4583 | // Setup mock issue for success case (matches GitHub API response format - the updated parent issue) |
| 4584 | mockIssue := &github.Issue{ |
| 4585 | Number: github.Ptr(42), |
| 4586 | Title: github.Ptr("Parent Issue"), |
| 4587 | Body: github.Ptr("This is the parent issue with reprioritized sub-issues"), |
| 4588 | State: github.Ptr("open"), |
| 4589 | HTMLURL: github.Ptr("https://github.com/owner/repo/issues/42"), |
| 4590 | User: &github.User{ |
| 4591 | Login: github.Ptr("testuser"), |
| 4592 | }, |
| 4593 | Labels: []*github.Label{ |
| 4594 | { |
| 4595 | Name: github.Ptr("enhancement"), |
| 4596 | Color: github.Ptr("84b6eb"), |
| 4597 | Description: github.Ptr("New feature or request"), |
| 4598 | }, |
| 4599 | }, |
| 4600 | } |
| 4601 | |
| 4602 | tests := []struct { |
| 4603 | name string |
| 4604 | mockedClient *http.Client |
| 4605 | requestArgs map[string]any |
| 4606 | expectError bool |
| 4607 | expectedIssue *github.Issue |
| 4608 | expectedErrMsg string |
| 4609 | }{ |
| 4610 | { |
| 4611 | name: "successful reprioritization with after_id", |
| 4612 | mockedClient: MockHTTPClientWithHandlers(map[string]http.HandlerFunc{ |
| 4613 | PatchReposIssuesSubIssuesPriorityByOwnerByRepoByIssueNumber: mockResponse(t, http.StatusOK, mockIssue), |
| 4614 | }), |
| 4615 | requestArgs: map[string]any{ |
| 4616 | "method": "reprioritize", |
| 4617 | "owner": "owner", |
| 4618 | "repo": "repo", |
| 4619 | "issue_number": float64(42), |
| 4620 | "sub_issue_id": float64(123), |
| 4621 | "after_id": float64(456), |
| 4622 | }, |
| 4623 | expectError: false, |
nothing calls this directly
no test coverage detected