-
Notifications
You must be signed in to change notification settings - Fork 0
온보딩 Domain User 계약 추가 #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| import Foundation | ||
| import ThirdParty | ||
|
|
||
| @DependencyClient | ||
| public struct UserClient: Sendable { | ||
| public var completeOnboarding: @Sendable (OnboardingDraft) async throws -> AuthSession | ||
| } | ||
|
|
||
| extension UserClient: TestDependencyKey { | ||
| public static let testValue = UserClient() | ||
| } | ||
|
|
||
| public extension DependencyValues { | ||
| var userClient: UserClient { | ||
| get { self[UserClient.self] } | ||
| set { self[UserClient.self] = newValue } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import Foundation | ||
|
|
||
| public enum UserError: Error, Equatable, Sendable { | ||
| case network | ||
| case unauthorized | ||
| case validation(message: String) | ||
| case updateFailed | ||
| case storage(message: String) | ||
| case unknown(message: String) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import Foundation | ||
|
|
||
| public enum Gender: String, Equatable, Hashable, Sendable, Codable { | ||
| case male | ||
| case female | ||
| case other | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import Foundation | ||
|
|
||
| public struct Interest: Equatable, Hashable, Sendable, Codable { | ||
| public var id: String | ||
| public var name: String | ||
|
|
||
| public init(id: String, name: String) { | ||
| self.id = id | ||
| self.name = name | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| import Foundation | ||
|
|
||
| public struct OnboardingDraft: Equatable, Sendable { | ||
| public var nickname: String | ||
| public var gender: Gender | ||
| public var birthDate: Date | ||
| public var interestIDs: [String] | ||
|
|
||
| public init( | ||
| nickname: String, | ||
| gender: Gender, | ||
| birthDate: Date, | ||
| interestIDs: [String] | ||
| ) { | ||
| self.nickname = nickname | ||
| self.gender = gender | ||
| self.birthDate = birthDate | ||
| self.interestIDs = interestIDs | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| import Foundation | ||
|
|
||
| public struct UserProfile: Equatable, Sendable, Codable { | ||
| public var nickname: String | ||
| public var gender: Gender | ||
| public var birthDate: Date | ||
| public var interestIDs: [String] | ||
|
|
||
| public init( | ||
| nickname: String, | ||
| gender: Gender, | ||
| birthDate: Date, | ||
| interestIDs: [String] | ||
| ) { | ||
| self.nickname = nickname | ||
| self.gender = gender | ||
| self.birthDate = birthDate | ||
| self.interestIDs = interestIDs | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import Domain | ||
| import XCTest | ||
|
|
||
| final class UserClientTests: XCTestCase { | ||
| func test_UserClient_testValue는_빈_클라이언트로_생성() { | ||
| // @DependencyClient 는 testValue = UserClient() 를 기본 제공한다. | ||
| // 미구현 endpoint 호출 시 issue를 내므로, 생성 가능성만 검증한다. | ||
| _ = UserClient.testValue | ||
| XCTAssertTrue(true) | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,70 @@ | ||||||||||||||||||||||||||||||||||||||
| import Domain | ||||||||||||||||||||||||||||||||||||||
| import XCTest | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| final class UserModelTests: XCTestCase { | ||||||||||||||||||||||||||||||||||||||
| func test_성별_rawValue와_동등성() { | ||||||||||||||||||||||||||||||||||||||
| XCTAssertEqual(Gender.male.rawValue, "male") | ||||||||||||||||||||||||||||||||||||||
| XCTAssertEqual(Gender.female.rawValue, "female") | ||||||||||||||||||||||||||||||||||||||
| XCTAssertEqual(Gender.other.rawValue, "other") | ||||||||||||||||||||||||||||||||||||||
| XCTAssertEqual(Gender.male, Gender.male) | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+5
to
+10
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
수정 예시+ func test_성별_codable_왕복() throws {
+ let data = try JSONEncoder().encode(Gender.other)
+ let decoded = try JSONDecoder().decode(Gender.self, from: data)
+ XCTAssertEqual(decoded, .other)
+ }As per coding guidelines, "모델 계약의 Equatable/Codable 및 Client testValue 동작을 검증한다." 📝 Committable suggestion
Suggested change
🤖 Prompt for AI AgentsSource: Coding guidelines |
||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| func test_관심사_동등성_비교() { | ||||||||||||||||||||||||||||||||||||||
| let a = Interest(id: "sports", name: "운동") | ||||||||||||||||||||||||||||||||||||||
| let b = Interest(id: "sports", name: "운동") | ||||||||||||||||||||||||||||||||||||||
| XCTAssertEqual(a, b) | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| func test_관심사_codable_왕복() throws { | ||||||||||||||||||||||||||||||||||||||
| let original = Interest(id: "music", name: "음악") | ||||||||||||||||||||||||||||||||||||||
| let data = try JSONEncoder().encode(original) | ||||||||||||||||||||||||||||||||||||||
| let decoded = try JSONDecoder().decode(Interest.self, from: data) | ||||||||||||||||||||||||||||||||||||||
| XCTAssertEqual(decoded, original) | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| func test_프로필_동등성_비교() { | ||||||||||||||||||||||||||||||||||||||
| let birthDate = Date(timeIntervalSince1970: 0) | ||||||||||||||||||||||||||||||||||||||
| let a = UserProfile( | ||||||||||||||||||||||||||||||||||||||
| nickname: "모지", | ||||||||||||||||||||||||||||||||||||||
| gender: .female, | ||||||||||||||||||||||||||||||||||||||
| birthDate: birthDate, | ||||||||||||||||||||||||||||||||||||||
| interestIDs: ["sports", "music"] | ||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||
| let b = UserProfile( | ||||||||||||||||||||||||||||||||||||||
| nickname: "모지", | ||||||||||||||||||||||||||||||||||||||
| gender: .female, | ||||||||||||||||||||||||||||||||||||||
| birthDate: birthDate, | ||||||||||||||||||||||||||||||||||||||
| interestIDs: ["sports", "music"] | ||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||
| XCTAssertEqual(a, b) | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| func test_프로필_codable_왕복() throws { | ||||||||||||||||||||||||||||||||||||||
| let original = UserProfile( | ||||||||||||||||||||||||||||||||||||||
| nickname: "모지", | ||||||||||||||||||||||||||||||||||||||
| gender: .other, | ||||||||||||||||||||||||||||||||||||||
| birthDate: Date(timeIntervalSince1970: 1_000), | ||||||||||||||||||||||||||||||||||||||
| interestIDs: ["travel"] | ||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||
| let data = try JSONEncoder().encode(original) | ||||||||||||||||||||||||||||||||||||||
| let decoded = try JSONDecoder().decode(UserProfile.self, from: data) | ||||||||||||||||||||||||||||||||||||||
| XCTAssertEqual(decoded, original) | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| func test_온보딩초안_동등성_비교() { | ||||||||||||||||||||||||||||||||||||||
| let birthDate = Date(timeIntervalSince1970: 2_000) | ||||||||||||||||||||||||||||||||||||||
| let a = OnboardingDraft( | ||||||||||||||||||||||||||||||||||||||
| nickname: "모지", | ||||||||||||||||||||||||||||||||||||||
| gender: .male, | ||||||||||||||||||||||||||||||||||||||
| birthDate: birthDate, | ||||||||||||||||||||||||||||||||||||||
| interestIDs: ["food"] | ||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||
| let b = OnboardingDraft( | ||||||||||||||||||||||||||||||||||||||
| nickname: "모지", | ||||||||||||||||||||||||||||||||||||||
| gender: .male, | ||||||||||||||||||||||||||||||||||||||
| birthDate: birthDate, | ||||||||||||||||||||||||||||||||||||||
| interestIDs: ["food"] | ||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||
| XCTAssertEqual(a, b) | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
UserClient.testValue의 검증 계약을 실제 테스트와 일치시키세요.현재 테스트는
UserClient.testValue생성만 확인합니다. README는 unimplemented endpoint 동작까지 검증한다고 설명합니다. Line 6의 주석도testValue의 선언 주체를 잘못 설명합니다.Projects/Domain/Tests/User/UserClientTests.swift#L5-L9: 테스트 주석과 이름을 생성 가능성 검증으로 명확히 하고, 불필요한XCTAssertTrue(true)를 제거하거나 실제 검증으로 교체하세요.Projects/Domain/README.md#L35-L39: 테스트 포인트를 “UserClient.testValue생성 가능성 검증”으로 수정하거나 실제 unimplemented 동작 검증을 추가하세요.As per coding guidelines: “테스트는 한국어 이름의 test_상황_기대결과 형식으로 작성하고, 모델 계약의 Equatable/Codable 및 Client testValue 동작을 검증한다.”
📍 Affects 2 files
Projects/Domain/Tests/User/UserClientTests.swift#L5-L9(this comment)Projects/Domain/README.md#L35-L39🤖 Prompt for AI Agents
Source: Coding guidelines