T-16: M0.1b — Make repo-wide bun test green: fix queue, shutdown-signal and research-workflow test failures
This commit is contained in:
parent
890761e0d5
commit
9c4e87cdfd
17 changed files with 366 additions and 266 deletions
|
|
@ -1,16 +1,12 @@
|
|||
import { readFileSync } from 'fs';
|
||||
import { afterEach, beforeEach, describe, expect, it, mock, spyOn } from 'bun:test';
|
||||
import * as fs from 'fs';
|
||||
import { afterEach, beforeEach, describe, expect, it, spyOn } from 'bun:test';
|
||||
import { ConfigLoaderError } from '../src/errors';
|
||||
import { EnvLoader } from '../src/loaders/env.loader';
|
||||
import { queueConfigSchema } from '../src/schemas';
|
||||
|
||||
// Mock fs module
|
||||
mock.module('fs', () => ({
|
||||
readFileSync: mock(() => ''),
|
||||
}));
|
||||
|
||||
describe('EnvLoader', () => {
|
||||
let loader: EnvLoader;
|
||||
let readFileSync: ReturnType<typeof spyOn>;
|
||||
const originalEnv = { ...process.env };
|
||||
|
||||
beforeEach(() => {
|
||||
|
|
@ -18,9 +14,11 @@ describe('EnvLoader', () => {
|
|||
for (const key in process.env) {
|
||||
delete process.env[key];
|
||||
}
|
||||
readFileSync = spyOn(fs, 'readFileSync').mockReturnValue('' as any);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
readFileSync?.mockRestore();
|
||||
// Restore original environment
|
||||
for (const key in process.env) {
|
||||
delete process.env[key];
|
||||
|
|
@ -371,17 +369,20 @@ KEY_WITHOUT_VALUE=
|
|||
|
||||
it('should warn on other file errors', () => {
|
||||
const consoleWarnSpy = spyOn(console, 'warn').mockImplementation(() => {});
|
||||
try {
|
||||
(readFileSync as any).mockImplementation(() => {
|
||||
const error: any = new Error('Permission denied');
|
||||
error.code = 'EACCES';
|
||||
throw error;
|
||||
});
|
||||
|
||||
(readFileSync as any).mockImplementation(() => {
|
||||
const error: any = new Error('Permission denied');
|
||||
error.code = 'EACCES';
|
||||
throw error;
|
||||
});
|
||||
loader = new EnvLoader();
|
||||
loader.load();
|
||||
|
||||
loader = new EnvLoader();
|
||||
loader.load();
|
||||
|
||||
expect(consoleWarnSpy).toHaveBeenCalled();
|
||||
expect(consoleWarnSpy).toHaveBeenCalled();
|
||||
} finally {
|
||||
consoleWarnSpy.mockRestore();
|
||||
}
|
||||
});
|
||||
|
||||
it('should try multiple env file paths', () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue