(t *testing.T)
| 140 | } |
| 141 | |
| 142 | func Test_UpdatePullRequest(t *testing.T) { |
| 143 | // Verify tool definition once |
| 144 | serverTool := UpdatePullRequest(translations.NullTranslationHelper) |
| 145 | tool := serverTool.Tool |
| 146 | require.NoError(t, toolsnaps.Test(tool.Name, tool)) |
| 147 | |
| 148 | assert.Equal(t, "update_pull_request", tool.Name) |
| 149 | assert.NotEmpty(t, tool.Description) |
| 150 | schema := tool.InputSchema.(*jsonschema.Schema) |
| 151 | assert.Contains(t, schema.Properties, "owner") |
| 152 | assert.Contains(t, schema.Properties, "repo") |
| 153 | assert.Contains(t, schema.Properties, "pullNumber") |
| 154 | assert.Contains(t, schema.Properties, "draft") |
| 155 | assert.Contains(t, schema.Properties, "title") |
| 156 | assert.Contains(t, schema.Properties, "body") |
| 157 | assert.Contains(t, schema.Properties, "state") |
| 158 | assert.Contains(t, schema.Properties, "base") |
| 159 | assert.Contains(t, schema.Properties, "maintainer_can_modify") |
| 160 | assert.Contains(t, schema.Properties, "reviewers") |
| 161 | assert.ElementsMatch(t, schema.Required, []string{"owner", "repo", "pullNumber"}) |
| 162 | |
| 163 | // Setup mock PR for success case |
| 164 | mockUpdatedPR := &github.PullRequest{ |
| 165 | Number: github.Ptr(42), |
| 166 | Title: github.Ptr("Updated Test PR Title"), |
| 167 | State: github.Ptr("open"), |
| 168 | HTMLURL: github.Ptr("https://github.com/owner/repo/pull/42"), |
| 169 | Body: github.Ptr("Updated test PR body."), |
| 170 | MaintainerCanModify: github.Ptr(false), |
| 171 | Draft: github.Ptr(false), |
| 172 | Base: &github.PullRequestBranch{ |
| 173 | Ref: github.Ptr("develop"), |
| 174 | }, |
| 175 | } |
| 176 | |
| 177 | mockClosedPR := &github.PullRequest{ |
| 178 | Number: github.Ptr(42), |
| 179 | Title: github.Ptr("Test PR"), |
| 180 | State: github.Ptr("closed"), // State updated |
| 181 | } |
| 182 | |
| 183 | // Mock PR for when there are no updates but we still need a response |
| 184 | mockPRWithReviewers := &github.PullRequest{ |
| 185 | Number: github.Ptr(42), |
| 186 | Title: github.Ptr("Test PR"), |
| 187 | State: github.Ptr("open"), |
| 188 | RequestedReviewers: []*github.User{ |
| 189 | {Login: github.Ptr("reviewer1")}, |
| 190 | {Login: github.Ptr("reviewer2")}, |
| 191 | }, |
| 192 | } |
| 193 | |
| 194 | tests := []struct { |
| 195 | name string |
| 196 | mockedClient *http.Client |
| 197 | requestArgs map[string]any |
| 198 | expectError bool |
| 199 | expectedPR *github.PullRequest |
nothing calls this directly
no test coverage detected