Skip to content

Commit 741e1c6

Browse files
committed
build: local driver test case
1 parent dfffa3c commit 741e1c6

File tree

5 files changed

+28
-12
lines changed

5 files changed

+28
-12
lines changed

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ npm-debug.log
1111
.DS_Store
1212

1313
# tests
14-
/test
14+
!tests/data/.gitkeep
15+
1516
/coverage
1617
/.nyc_output
1718

1819
# dist
19-
dist
20+
dist

tests/data/.gitkeep

Whitespace-only changes.

tests/e2e/s3-driver.spec.ts renamed to tests/e2e/local-driver.spec.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,27 @@
11
import { INestApplication } from '@nestjs/common';
22
import { Test } from '@nestjs/testing';
33
import { AppModule } from '../src/app.module';
4+
import { StorageService } from '../../lib';
45

5-
describe('s3 driver', () => {
6+
describe('local driver', async () => {
67
let app: INestApplication;
8+
let storageService;
79

810
beforeEach(async () => {
911
const moduleRef = await Test.createTestingModule({
10-
imports: [AppModule.withStorage()],
12+
imports: [AppModule.withLocalStorage()],
1113
}).compile();
1214

1315
app = moduleRef.createNestApplication();
1416
await app.init();
1517
});
1618

17-
it(`should load configuration with "s3 driver"`, () => {
18-
expect('a').toEqual('a');
19+
it(`should load configuration with "local driver"`, async () => {
20+
storageService = app.get<StorageService>(StorageService);
1921
});
2022

23+
it(`put `);
24+
2125
afterEach(async () => {
2226
await app.close();
2327
});

tests/src/app.module.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,26 @@ import { StorageService } from '../../lib/storage.service';
66
@Module({})
77
export class AppModule {
88
constructor(private readonly storageService: StorageService) {
9-
console.log(storageService);
9+
console.log('AppModule constructor', storageService);
1010
}
1111

12-
static withStorage(): DynamicModule {
12+
static withLocalStorage(): DynamicModule {
13+
console.log('withLocalStorage');
1314
return {
1415
module: AppModule,
15-
imports: [StorageModule.forRoot()],
16+
imports: [
17+
StorageModule.forRoot({
18+
default: 'local',
19+
disks: {
20+
local: {
21+
driver: 'local',
22+
config: {
23+
root: process.cwd(),
24+
},
25+
},
26+
},
27+
}),
28+
],
1629
};
1730
}
1831
}

tests/tsconfig.spec.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
"compilerOptions": {
44
"outDir": "../../dist/out-tsc",
55
"module": "commonjs",
6-
"types": ["jest", "node"],
7-
"rootDir": ".",
8-
"baseUrl": "."
6+
"types": ["jest", "node"]
97
},
108
"include": [
119
"**/*.spec.ts",

0 commit comments

Comments
 (0)