Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Commit ebdb569

Browse files
Van-QAlouis-jan
authored andcommitted
chore: add test_data fake config
1 parent 230e017 commit ebdb569

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

cortex-js/src/infrastructure/commanders/test/helpers.command.spec.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ import { spy, Stub, stubMethod } from 'hanbi';
33
import { CommandTestFactory } from 'nest-commander-testing';
44
import { CommandModule } from '@/command.module';
55
import { LogService } from '@/infrastructure/commanders/test/log.service';
6+
import { FileManagerService } from '@/infrastructure/services/file-manager/file-manager.service';
7+
68
import axios from 'axios';
9+
import { join } from 'path';
10+
import { rmSync } from 'fs';
711

812
let commandInstance: TestingModule,
913
exitSpy: Stub<typeof process.exit>,
@@ -24,9 +28,29 @@ beforeEach(
2428
.overrideProvider(LogService)
2529
.useValue({ log: spy().handler })
2630
.compile();
27-
res();
2831
stdoutSpy.reset();
2932
stderrSpy.reset();
33+
34+
const fileService =
35+
await commandInstance.resolve<FileManagerService>(FileManagerService);
36+
37+
// Attempt to create test folder
38+
await fileService.writeConfigFile({
39+
dataFolderPath: join(__dirname, 'test_data'),
40+
});
41+
res();
42+
}),
43+
);
44+
45+
afterEach(
46+
() =>
47+
new Promise<void>(async (res) => {
48+
// Attempt to clean test folder
49+
rmSync(join(__dirname, 'test_data'), {
50+
recursive: true,
51+
force: true,
52+
});
53+
res();
3054
}),
3155
);
3256

cortex-js/src/infrastructure/commanders/test/models.command.spec.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { CommandModule } from '@/command.module';
55
import { join } from 'path';
66
import { rmSync } from 'fs';
77
import { timeout } from '@/infrastructure/commanders/test/helpers.command.spec';
8+
import { FileManagerService } from '@/infrastructure/services/file-manager/file-manager.service';
89

910
let commandInstance: TestingModule;
1011

@@ -17,6 +18,14 @@ beforeEach(
1718
// .overrideProvider(LogService)
1819
// .useValue({})
1920
.compile();
21+
const fileService =
22+
await commandInstance.resolve<FileManagerService>(FileManagerService);
23+
24+
// Attempt to create test folder
25+
await fileService.writeConfigFile({
26+
dataFolderPath: join(__dirname, 'test_data'),
27+
});
28+
2029
res();
2130
}),
2231
);

0 commit comments

Comments
 (0)