-
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.
[Feat/#101] challengeRepository 추가적인 도메인 에러 상황 테스트 코드 작성
- Loading branch information
Showing
13 changed files
with
238 additions
and
26 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,18 +60,3 @@ extension GetChallengeResult { | |
) | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
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
27 changes: 27 additions & 0 deletions
27
...ests/Sources/ChallengeRepositoryTests/GetLockChallengeTest/GetLockChallengeMockData.swift
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,27 @@ | ||
// | ||
// GetLockChallengeMockData.swift | ||
// Data | ||
// | ||
// Created by 류희재 on 11/6/24. | ||
// Copyright © 2024 HMH-iOS. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
import Domain | ||
import Networks | ||
|
||
extension GetLockResult { | ||
static public var expectedData: [Bool] { | ||
return [true, false] | ||
} | ||
} | ||
|
||
extension GetLockResult { | ||
static public var resultData: [GetLockResult] { | ||
return [ | ||
.init(isLockToday: true), | ||
.init(isLockToday: false) | ||
] | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
...ta/Tests/Sources/ChallengeRepositoryTests/GetLockChallengeTest/GetLockChallengeTest.swift
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,62 @@ | ||
// | ||
// GetLockChallengeTest.swift | ||
// DataTests | ||
// | ||
// Created by 류희재 on 11/6/24. | ||
// Copyright © 2024 HMH-iOS. All rights reserved. | ||
// | ||
|
||
import XCTest | ||
import Combine | ||
|
||
import Networks | ||
import Core | ||
import Domain | ||
|
||
/// 당일 잠금 여부 확인 API 데이터 변환 테스트 | ||
extension ChallegeRepositoryTests { | ||
func test_당일잠금여부확인_정상적인변환() { | ||
let testCases = Array(zip(GetLockResult.expectedData, GetLockResult.resultData)) | ||
|
||
let expectation = XCTestExpectation(description: "당일 잠금 여부 확인 API 관련 레포지토리 변환이 정상적으로 성공했습니다!") | ||
|
||
expectation.expectedFulfillmentCount = testCases.count | ||
for (expectedData, resultData) in testCases { | ||
mockService.getLockChallengeResult = Just(resultData) | ||
.setFailureType(to: HMHNetworkError.self) | ||
.eraseToAnyPublisher() | ||
|
||
sut.getLockChallenge() | ||
.sink(receiveCompletion: { completion in | ||
if case .failure(let error) = completion { | ||
XCTFail("챌린지 성공 여부 리스트 전송 API 변환 중 실패했습니다: 에러 \(error)") | ||
} | ||
}, receiveValue: valueHandler(expectation: expectation, expectedValue: expectedData)) | ||
.store(in: cancelBag) | ||
} | ||
|
||
wait(for: [expectation], timeout: 1.0 * Double(testCases.count)) | ||
} | ||
|
||
func test_당일잠금여부확인_네트워크에러발생시_에러반환() { | ||
|
||
let testCases = HMHNetworkError.mockNetworkError | ||
let expectation = XCTestExpectation(description: "에러 발생 시 네트워크 에러 반환") | ||
|
||
for expected in testCases { | ||
mockService.postLockChallengeResult = Fail(error: expected).eraseToAnyPublisher() | ||
|
||
sut.postLockChallenge() | ||
.sink( | ||
receiveCompletion: handleCompletion( | ||
expectedError: .networkError, | ||
expectation: expectation | ||
), | ||
receiveValue: failureExpectedValueHandler() | ||
) | ||
.store(in: cancelBag) | ||
|
||
} | ||
wait(for: [expectation], timeout: 1.0 * Double(testCases.count)) | ||
} | ||
} |
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