test(ai-review comment): 補齊留言更新與 TLS 設定覆蓋
This commit is contained in:
+17
-1
@@ -1,7 +1,7 @@
|
||||
import { describe, it, afterEach, mock } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import axios from 'axios';
|
||||
import { getPRDiff, filterDiff, postComment, postPullReviewComment, getCommitMessageBySha, getBranchHeadCommitMessage, shouldSkipBotCommit, getBotReviewOutcome } from './gitea.js';
|
||||
import { getPRDiff, filterDiff, postComment, updateComment, postPullReviewComment, getCommitMessageBySha, getBranchHeadCommitMessage, shouldSkipBotCommit, getBotReviewOutcome } from './gitea.js';
|
||||
|
||||
afterEach(() => mock.restoreAll());
|
||||
|
||||
@@ -57,6 +57,22 @@ describe('gitea', () => {
|
||||
await assert.rejects(() => postComment('test'), /api error/);
|
||||
});
|
||||
|
||||
it('updateComment patches an existing issue comment with body', async () => {
|
||||
let capturedUrl, capturedBody, capturedOpts;
|
||||
mock.method(axios, 'patch', async (url, body, opts) => {
|
||||
capturedUrl = url;
|
||||
capturedBody = body;
|
||||
capturedOpts = opts;
|
||||
return { data: { id: 123, body: body.body } };
|
||||
});
|
||||
const result = await updateComment(123, 'updated body');
|
||||
assert.deepEqual(result, { id: 123, body: 'updated body' });
|
||||
assert.ok(capturedUrl.includes('/api/v1/repos/'));
|
||||
assert.ok(capturedUrl.endsWith('/issues/comments/123'));
|
||||
assert.equal(capturedBody.body, 'updated body');
|
||||
assert.ok(capturedOpts.headers['Authorization'].startsWith('token '));
|
||||
});
|
||||
|
||||
it('postPullReviewComment posts an inline review comment to the pulls reviews API', async () => {
|
||||
let capturedUrl, capturedBody, capturedOpts;
|
||||
mock.method(axios, 'post', async (url, body, opts) => {
|
||||
|
||||
Reference in New Issue
Block a user