Skip to content

Commit

Permalink
[IDLE-000] Resolve Conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
tgyuuAn committed Feb 20, 2025
2 parents 44beac5 + 302c4f1 commit 86e886f
Showing 1 changed file with 15 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ package com.idle.data.repository.auth
import com.idle.datastore.datasource.TokenDataSource
import com.idle.datastore.datasource.UserInfoDataSource
import com.idle.domain.model.auth.UserType
import com.idle.domain.model.profile.CenterProfile
import com.idle.domain.model.profile.WorkerProfile
import com.idle.domain.repositorry.auth.AuthRepository
import com.idle.domain.repositorry.auth.TokenRepository
import com.idle.domain.repositorry.profile.ProfileRepository
import com.idle.network.model.token.TokenResponse
import com.idle.network.source.auth.AuthDataSource
import io.mockk.Runs
Expand All @@ -20,25 +25,29 @@ class AuthRepositoryImplTest {
private lateinit var authDataSource: AuthDataSource
private lateinit var tokenDataSource: TokenDataSource
private lateinit var userInfoDataSource: UserInfoDataSource
private lateinit var authRepository: AuthRepositoryImpl
private lateinit var tokenRepository: TokenRepositoryImpl
private lateinit var authRepository: AuthRepository
private lateinit var tokenRepository: TokenRepository
private lateinit var profileRepository: ProfileRepository

@BeforeEach
fun setUp() {
authDataSource = mockk()
tokenDataSource = mockk()
userInfoDataSource = mockk()
tokenRepository = mockk()
profileRepository = mockk()
authRepository = AuthRepositoryImpl(
authDataSource = authDataSource,
tokenDataSource = tokenDataSource,
userInfoDataSource = userInfoDataSource,
profileRepository = profileRepository,
tokenRepository = tokenRepository,
)

coEvery { tokenDataSource.setAccessToken(any()) } just Runs
coEvery { tokenDataSource.setRefreshToken(any()) } just Runs
coEvery { userInfoDataSource.setUserType(any()) } just Runs
coEvery { userInfoDataSource.setUserInfo(any()) } just Runs
coEvery { tokenDataSource.clearToken() } just Runs
coEvery { userInfoDataSource.clearUserType() } just Runs
coEvery { userInfoDataSource.clearUserInfo() } just Runs
Expand All @@ -51,7 +60,9 @@ class AuthRepositoryImplTest {
fun `센터장이 로그인 성공했을 경우 토큰을 저장하고 디바이스 토큰을 서버로 보낸다`() = runTest {
// Given
val tokenResponse = TokenResponse("accessToken", "refreshToken")
val centerProfile = mockk<CenterProfile>()
coEvery { authDataSource.signInCenter(any()) } returns Result.success(tokenResponse)
coEvery { profileRepository.getMyCenterProfile() } returns Result.success(centerProfile)

// When
val result = authRepository.signInCenter("identifier", "password")
Expand All @@ -68,7 +79,9 @@ class AuthRepositoryImplTest {
fun `요양보호사가 회원가입에 성공했을 경우 토큰을 저장하고 디바이스 토큰을 서버로 보낸다`() = runTest {
// Given
val tokenResponse = TokenResponse("accessToken", "refreshToken")
val workerProfile = mockk<WorkerProfile>()
coEvery { authDataSource.signUpWorker(any()) } returns Result.success(tokenResponse)
coEvery { profileRepository.getMyWorkerProfile() } returns Result.success(workerProfile)

// When
val result = authRepository.signUpWorker("name", 1990, "male", "01012345678", "road", "lot")
Expand All @@ -81,23 +94,6 @@ class AuthRepositoryImplTest {
coVerify { tokenRepository.postDeviceToken("testToken", "CARER") }
}

@Test
fun `요양보호사가 로그인했을 경우 토큰을 저장하고 디바이스 토큰을 서버로 보낸다`() = runTest {
// Given
val tokenResponse = TokenResponse("accessToken", "refreshToken")
coEvery { authDataSource.signInWorker(any()) } returns Result.success(tokenResponse)

// When
val result = authRepository.signInWorker("01012345678", "authCode")

// Then
assertTrue(result.isSuccess)
coVerify { tokenDataSource.setAccessToken("accessToken") }
coVerify { tokenDataSource.setRefreshToken("refreshToken") }
coVerify { userInfoDataSource.setUserType(UserType.WORKER.apiValue) }
coVerify { tokenRepository.postDeviceToken("testToken", "CARER") }
}

@Test
fun `요양보호사가 로그아웃했을 경우 토큰을 제거한다`() = runTest {
// Given
Expand Down

0 comments on commit 86e886f

Please sign in to comment.