-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #344 from boostcampwm2023/BE-feature/login
로그인 동시성 해결
- Loading branch information
Showing
10 changed files
with
41 additions
and
116 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -2,7 +2,6 @@ import { Test, TestingModule } from '@nestjs/testing'; | |
import { UsersService } from './users.service'; | ||
import { PrismaService } from '../prisma/prisma.service'; | ||
import generateUuid from '../utils/uuid'; | ||
import { PrismaClientKnownRequestError } from '@prisma/client/runtime/library'; | ||
|
||
describe('UsersService', () => { | ||
let usersService: UsersService; | ||
|
@@ -17,7 +16,7 @@ describe('UsersService', () => { | |
useValue: { | ||
user: { | ||
findUnique: jest.fn(), | ||
create: jest.fn(), | ||
upsert: jest.fn(), | ||
}, | ||
}, | ||
}, | ||
|
@@ -55,37 +54,19 @@ describe('UsersService', () => { | |
await expect(user).resolves.toBeNull(); | ||
}); | ||
|
||
it('createUser created', async () => { | ||
it('getOrCreateUser', async () => { | ||
const testUser = { | ||
uuid: generateUuid(), | ||
email: '[email protected]', | ||
provider: 'kakao', | ||
}; | ||
jest.spyOn(prisma.user, 'create').mockResolvedValue(testUser); | ||
jest.spyOn(prisma.user, 'upsert').mockResolvedValue(testUser); | ||
|
||
const user = usersService.createUser({ | ||
const user = usersService.getOrCreateUser({ | ||
email: '[email protected]', | ||
provider: 'kakao', | ||
}); | ||
|
||
await expect(user).resolves.toEqual(testUser); | ||
}); | ||
|
||
it('createUser user already exists', async () => { | ||
jest | ||
.spyOn(prisma.user, 'create') | ||
.mockRejectedValue( | ||
new PrismaClientKnownRequestError( | ||
'Unique constraint failed on the constraint: `User_email_provider_key`', | ||
{ code: 'P2025', clientVersion: '' }, | ||
), | ||
); | ||
|
||
const user = usersService.createUser({ | ||
email: '[email protected]', | ||
provider: 'kakao', | ||
}); | ||
|
||
await expect(user).rejects.toThrow(PrismaClientKnownRequestError); | ||
}); | ||
}); |
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