test(gitea): 補 .reviewignore 解析與載入測試
This commit is contained in:
+29
-1
@@ -1,7 +1,7 @@
|
|||||||
import { describe, it, afterEach, mock } from 'node:test';
|
import { describe, it, afterEach, mock } from 'node:test';
|
||||||
import assert from 'node:assert/strict';
|
import assert from 'node:assert/strict';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { getPRDiff, filterDiff, postComment, postPullReviewComment, postPullReview, getCommitMessageBySha, getBranchHeadCommitMessage, shouldSkipBotCommit, getBotReviewOutcome, listPullReviews, getPullReviewComments, listAllReviewComments, resolvePullReviewComment, getFileContentAtRef } from '../gitea.js';
|
import { getPRDiff, filterDiff, parseReviewIgnore, getReviewIgnore, DEFAULT_REVIEW_IGNORE, postComment, postPullReviewComment, postPullReview, getCommitMessageBySha, getBranchHeadCommitMessage, shouldSkipBotCommit, getBotReviewOutcome, listPullReviews, getPullReviewComments, listAllReviewComments, resolvePullReviewComment, getFileContentAtRef } from '../gitea.js';
|
||||||
|
|
||||||
afterEach(() => mock.restoreAll());
|
afterEach(() => mock.restoreAll());
|
||||||
|
|
||||||
@@ -259,3 +259,31 @@ describe('filterDiff', () => {
|
|||||||
assert.ok(result.includes('src/main.js'));
|
assert.ok(result.includes('src/main.js'));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('parseReviewIgnore', () => {
|
||||||
|
it('parses prefixes, skipping blanks and comments', () => {
|
||||||
|
const text = '# comment\n\n.gitea/\n dist/ \n# another\nREADME.md\n';
|
||||||
|
assert.deepEqual(parseReviewIgnore(text), ['.gitea/', 'dist/', 'README.md']);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns an empty array for empty/nullish input', () => {
|
||||||
|
assert.deepEqual(parseReviewIgnore(''), []);
|
||||||
|
assert.deepEqual(parseReviewIgnore(null), []);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('getReviewIgnore', () => {
|
||||||
|
it('uses patterns fetched from .reviewignore when present', async () => {
|
||||||
|
mock.method(axios, 'get', async () => ({
|
||||||
|
data: { content: Buffer.from('a/\nb/\n# c\n').toString('base64'), encoding: 'base64' },
|
||||||
|
}));
|
||||||
|
const patterns = await getReviewIgnore();
|
||||||
|
assert.deepEqual(patterns, ['a/', 'b/']);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('falls back to the default list when .reviewignore is missing/empty', async () => {
|
||||||
|
mock.method(axios, 'get', async () => ({ data: {} }));
|
||||||
|
const patterns = await getReviewIgnore();
|
||||||
|
assert.deepEqual(patterns, DEFAULT_REVIEW_IGNORE);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user