-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into BC-4374-submission-due-date
- Loading branch information
Showing
262 changed files
with
6,720 additions
and
2,826 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 48 additions & 21 deletions
69
apps/server/src/console/api-test/database-management.console.api.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,79 @@ | ||
import { INestApplicationContext } from '@nestjs/common'; | ||
import { BootstrapConsole, ConsoleService } from 'nestjs-console'; | ||
import { ConsoleWriterService } from '@shared/infra/console'; | ||
import { ServerConsoleModule } from '@src/console/console.module'; | ||
import { CommanderError } from 'commander'; | ||
import { execute, TestBootstrapConsole } from './test-bootstrap.console'; | ||
import { BootstrapConsole, ConsoleService } from 'nestjs-console'; | ||
import { TestBootstrapConsole, execute } from './test-bootstrap.console'; | ||
|
||
describe('DatabaseManagementConsole (API)', () => { | ||
let app: INestApplicationContext; | ||
let console: BootstrapConsole; | ||
let bootstrap: BootstrapConsole; | ||
let consoleService: ConsoleService; | ||
beforeAll(async () => { | ||
console = new TestBootstrapConsole({ | ||
let consoleWriter: ConsoleWriterService; | ||
|
||
beforeEach(async () => { | ||
bootstrap = new TestBootstrapConsole({ | ||
module: ServerConsoleModule, | ||
useDecorators: true, | ||
}); | ||
app = await console.init(); | ||
app = await bootstrap.init(); | ||
await app.init(); | ||
consoleService = app.get(ConsoleService); | ||
consoleWriter = app.get(ConsoleWriterService); | ||
}); | ||
|
||
afterAll(async () => { | ||
afterEach(async () => { | ||
consoleService.resetCli(); | ||
await app.close(); | ||
}); | ||
|
||
describe('Command "database"', () => { | ||
beforeEach(() => { | ||
const setup = () => { | ||
const cli = consoleService.getCli('database'); | ||
const exitFn = (err: CommanderError) => { | ||
if (err.exitCode !== 0) throw err; | ||
}; | ||
cli?.exitOverride(exitFn); | ||
const rootCli = consoleService.getRootCli(); | ||
rootCli.exitOverride(exitFn); | ||
}); | ||
const spyConsoleWriterInfo = jest.spyOn(consoleWriter, 'info'); | ||
return { spyConsoleWriterInfo }; | ||
}; | ||
describe('when command not exists', () => { | ||
it('should fail for unknown command', async () => { | ||
setup(); | ||
await expect(execute(bootstrap, ['database', 'not_existing_command'])).rejects.toThrow( | ||
`error: unknown command 'not_existing_command'` | ||
); | ||
|
||
afterEach(() => { | ||
consoleService.resetCli(); | ||
consoleService.resetCli(); | ||
}); | ||
}); | ||
|
||
it('should fail for unknown command', async () => { | ||
await expect(execute(console, ['database', 'not_existing_command'])).rejects.toThrow( | ||
`error: unknown command 'not_existing_command'` | ||
); | ||
}); | ||
it('should provide command "seed"', async () => { | ||
await execute(console, ['database', 'seed']); | ||
}); | ||
it('should provide command "export"', async () => { | ||
await execute(console, ['database', 'export']); | ||
describe('when command exists', () => { | ||
it('should provide command "seed"', async () => { | ||
const { spyConsoleWriterInfo } = setup(); | ||
|
||
await execute(bootstrap, ['database', 'seed']); | ||
|
||
expect(spyConsoleWriterInfo).toBeCalled(); | ||
}); | ||
|
||
it('should provide command "export"', async () => { | ||
const { spyConsoleWriterInfo } = setup(); | ||
|
||
await execute(bootstrap, ['database', 'export']); | ||
|
||
expect(spyConsoleWriterInfo).toBeCalled(); | ||
}); | ||
|
||
it('should provide command "sync-indexes"', async () => { | ||
const { spyConsoleWriterInfo } = setup(); | ||
|
||
await execute(bootstrap, ['database', 'sync-indexes']); | ||
|
||
expect(spyConsoleWriterInfo).toBeCalled(); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
apps/server/src/modules/authentication/strategy/jwt-validation.adapter.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
apps/server/src/modules/authentication/strategy/jwt-validation.adapter.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.