-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
backend/user-service/__tests__/models/user.repository.test.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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { MongoDBContainer, StartedMongoDBContainer } from '@testcontainers/mongodb' | ||
import logger from '../../src/common/logger.util' | ||
import connectToDatabase from '../../src/common/mongodb.util' | ||
import { findOneUserByUsername } from '../../src/models/user.repository' | ||
|
||
describe('UserRepository', () => { | ||
let startedContainer: StartedMongoDBContainer | ||
|
||
beforeAll(async () => { | ||
const container: MongoDBContainer = new MongoDBContainer().withExposedPorts(27017) | ||
startedContainer = await container.start() | ||
|
||
const connectionString = `${startedContainer.getConnectionString()}?directConnection=true` | ||
logger.info(`[Index Test] MongoDB container started on ${connectionString}`) | ||
|
||
await connectToDatabase(connectionString) | ||
}, 60000) | ||
|
||
afterAll(async () => { | ||
await startedContainer.stop() | ||
logger.info(`[Index Test] MongoDB container stopped`) | ||
}) | ||
|
||
describe('findOneUserByUsername', () => { | ||
it('should return null when no user found', async () => { | ||
const user = await findOneUserByUsername('') | ||
expect(user).toBeNull() | ||
}) | ||
}) | ||
}) |