mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-09-14 23:22:54 +00:00
test: replace console.warn with logger capture in loadIgnoreRules error handling
This commit is contained in:
parent
4379c1e48a
commit
67d740dd19
1 changed files with 4 additions and 3 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { describe, it, expect, beforeAll, beforeEach, afterAll, afterEach, vi } from 'vitest';
|
||||
import { describe, it, expect, beforeAll, beforeEach, afterAll, afterEach } from 'vitest';
|
||||
import fs from 'fs/promises';
|
||||
import path from 'path';
|
||||
import os from 'os';
|
||||
|
|
@ -8,6 +8,7 @@ import {
|
|||
loadIgnoreRules,
|
||||
createIgnoreFilter,
|
||||
} from '../../src/config/ignore-service.js';
|
||||
import { _captureLogger } from '../../src/core/logger.js';
|
||||
|
||||
describe('shouldIgnorePath', () => {
|
||||
describe('version control directories', () => {
|
||||
|
|
@ -574,11 +575,11 @@ describe('loadIgnoreRules — error handling', () => {
|
|||
await fs.writeFile(gitignorePath, 'data/\n');
|
||||
await fs.chmod(gitignorePath, 0o000);
|
||||
|
||||
const warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {});
|
||||
const cap = _captureLogger();
|
||||
const result = await loadIgnoreRules(tmpDir);
|
||||
// Should still return (null or partial), not throw
|
||||
expect(result).toBeNull();
|
||||
expect(warnSpy).toHaveBeenCalledWith(expect.stringContaining('.gitignore'));
|
||||
expect(cap.records().some((r) => String(r.msg ?? '').includes('.gitignore'))).toBe(true);
|
||||
|
||||
cap.restore();
|
||||
await fs.chmod(gitignorePath, 0o644);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue