Skip to content

클래스 API 계약 테스트를 현재 모듈 구조에 맞춤 - #77

Merged
Roy-wonji merged 1 commit into
developfrom
feature/class-api-contract-tests-20261026
Oct 26, 2026
Merged

Roy-wonji merged 1 commit into
developfrom
feature/class-api-contract-tests-20261026

Conversation

@Roy-wonji

Copy link
Copy Markdown
Contributor

변경 내용

  • ClassDomain 계약 테스트가 분리된 APIEndpoint 모듈을 직접 가져오도록 수정
  • 통합된 ClassRepositoryImpl 및 ClassLocalAIUseCaseDependency 이름으로 테스트 참조 갱신
  • 서버 요청과 응답, 오류 매핑에 관한 기존 검증 유지

검증

  • tuist test ClassDomain --no-binary-cache --device 'Picke-Preview-375' 통과
  • Ticket, Member, Recommendation, Topic, Battle, Debate, Result 계약 테스트 모두 통과
  • 실기 Foundation Models 감사 테스트 4개는 환경 변수 미설정으로 건너뜀

확인 범위

이 PR은 로컬 계약 테스트 수정입니다. 인증된 운영 서버 API 응답은 Device Hub 화면 접근 오류로 아직 재검증하지 못했습니다.

이동된 APIEndpoint와 공통 유틸 모듈을 테스트에서 직접 가져옵니다.
통합된 클래스 Repository와 로컬 AI UseCase 이름으로 테스트 참조를 갱신합니다.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-10-26T06:49:12.673803Z 8b103b4 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

전반적으로 ClassAIChatUseCase 및 ClassAIFeedbackUseCase가 ClassLocalAIUseCase로 통합되었고, 관련 종속성 및 메서드 호출이 업데이트되었습니다. 또한, 여러 API 계약 테스트에서 ClassRepositoryImpl로의 리팩토링 및 APIEndpoint 모듈 직접 참조가 발생했습니다.

주요 문제는 Domain 계층의 테스트에서 APIEndpoint 모듈을 직접 가져오는 것인데, 이는 프로젝트의 Clean Architecture 및 모듈 종속성 규칙(Presentation → Domain ← Data, Network는 Data만 참조)을 위반합니다. Domain 계층은 Data 계층의 인터페이스에만 의존해야 합니다.

사소한 문제로는 테스트 헬퍼로 추가된 FeedbackUseCaseStub이 final 클래스로 선언되지 않은 점이 있습니다.

#endif
}

private struct FeedbackUseCaseStub: ClassLocalAIInterface {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 [P4] Readability

FeedbackUseCaseStub은 구조체로 선언되었으므로 final을 사용할 수 없습니다. 그러나 private 가시성을 고려할 때, 이 타입을 class로 변경하여 final로 선언하는 것을 고려할 수 있습니다. struct로 유지하는 것이 의도된 설계라면 이 코멘트는 무시해도 좋습니다.

Suggested change
private struct FeedbackUseCaseStub: ClassLocalAIInterface {
private final class FeedbackUseCaseStub: ClassLocalAIInterface {

@@ -1,4 +1,5 @@
@testable import ClassDomain
import APIEndpoint

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 [P2] Major

Domain 모듈의 테스트에서 APIEndpoint 모듈을 직접 가져오는 것은 아키텍처 규칙(Network는 Data 계층에서만 참조되어야 함)을 위반합니다. Domain 계층은 DataInterface 프로토콜을 통해서만 Data 계층과 상호작용해야 합니다. 테스트 시에는 DataInterface를 준수하는 Mock/Stub 객체를 사용하여 의존성을 주입해야 합니다.

APIEndpoint가 포함된 Network 또는 Data 계층의 모듈에 대한 직접적인 의존성은 Domain 계층에서 제거되어야 합니다. 이 테스트는 ClassRepositoryInterface와 같은 DomainInterface에 정의된 프로토콜을 사용하고, 해당 프로토콜의 구현체(예: ClassRepositoryImpl)가 APIEndpoint를 사용하는 형태로 이루어져야 합니다.

@@ -1,4 +1,5 @@
@testable import ClassDomain
import APIEndpoint

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 [P2] Major

Domain 모듈의 테스트에서 APIEndpoint 모듈을 직접 가져오는 것은 아키텍처 규칙(Network는 Data 계층에서만 참조되어야 함)을 위반합니다. Domain 계층은 DataInterface 프로토콜을 통해서만 Data 계층과 상호작용해야 합니다. 테스트 시에는 DataInterface를 준수하는 Mock/Stub 객체를 사용하여 의존성을 주입해야 합니다.

APIEndpoint가 포함된 Network 또는 Data 계층의 모듈에 대한 직접적인 의존성은 Domain 계층에서 제거되어야 합니다. 이 테스트는 ClassRepositoryInterface와 같은 DomainInterface에 정의된 프로토콜을 사용하고, 해당 프로토콜의 구현체(예: ClassRepositoryImpl)가 APIEndpoint를 사용하는 형태로 이루어져야 합니다.

@@ -1,4 +1,5 @@
@testable import ClassDomain
import APIEndpoint

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 [P2] Major

Domain 모듈의 테스트에서 APIEndpoint 모듈을 직접 가져오는 것은 아키텍처 규칙(Network는 Data 계층에서만 참조되어야 함)을 위반합니다. Domain 계층은 DataInterface 프로토콜을 통해서만 Data 계층과 상호작용해야 합니다. 테스트 시에는 DataInterface를 준수하는 Mock/Stub 객체를 사용하여 의존성을 주입해야 합니다.

APIEndpoint가 포함된 Network 또는 Data 계층의 모듈에 대한 직접적인 의존성은 Domain 계층에서 제거되어야 합니다. 이 테스트는 ClassRepositoryInterface와 같은 DomainInterface에 정의된 프로토콜을 사용하고, 해당 프로토콜의 구현체(예: ClassRepositoryImpl)가 APIEndpoint를 사용하는 형태로 이루어져야 합니다.

ClassRepositoryImpl()
}
)
let live = withDependencies {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 [P3] Minor

ClassLiveRepository가 제거되고 ClassRepositoryImpl이 직접 withDependencies 블록 내에서 인스턴스화되는 것은 TCA의 종속성 주입 패턴에 더 적합합니다. 이는 ClassRepositoryImpl이 환경 종속성(예: networkClient)을 올바르게 사용하도록 설계되었음을 나타냅니다. 잘 리팩터링되었습니다.

@@ -1,22 +1,24 @@
@testable import ClassDomain
import APIEndpoint

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 [P2] Major

Domain 모듈의 테스트에서 APIEndpoint 모듈을 직접 가져오는 것은 아키텍처 규칙(Network는 Data 계층에서만 참조되어야 함)을 위반합니다. Domain 계층은 DataInterface 프로토콜을 통해서만 Data 계층과 상호작용해야 합니다. 테스트 시에는 DataInterface를 준수하는 Mock/Stub 객체를 사용하여 의존성을 주입해야 합니다.

APIEndpoint가 포함된 Network 또는 Data 계층의 모듈에 대한 직접적인 의존성은 Domain 계층에서 제거되어야 합니다. 이 테스트는 ClassRepositoryInterface와 같은 DomainInterface에 정의된 프로토콜을 사용하고, 해당 프로토콜의 구현체(예: ClassRepositoryImpl)가 APIEndpoint를 사용하는 형태로 이루어져야 합니다.

@@ -1,4 +1,5 @@
@testable import ClassDomain
import APIEndpoint

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 [P2] Major

Domain 모듈의 테스트에서 APIEndpoint 모듈을 직접 가져오는 것은 아키텍처 규칙(Network는 Data 계층에서만 참조되어야 함)을 위반합니다. Domain 계층은 DataInterface 프로토콜을 통해서만 Data 계층과 상호작용해야 합니다. 테스트 시에는 DataInterface를 준수하는 Mock/Stub 객체를 사용하여 의존성을 주입해야 합니다.

APIEndpoint가 포함된 Network 또는 Data 계층의 모듈에 대한 직접적인 의존성은 Domain 계층에서 제거되어야 합니다. 이 테스트는 ClassRepositoryInterface와 같은 DomainInterface에 정의된 프로토콜을 사용하고, 해당 프로토콜의 구현체(예: ClassRepositoryImpl)가 APIEndpoint를 사용하는 형태로 이루어져야 합니다.

@@ -1,5 +1,6 @@
@testable import ClassDomain
import ClassDomainInterface
import APIEndpoint

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 [P2] Major

Domain 모듈의 테스트에서 APIEndpoint 모듈을 직접 가져오는 것은 아키텍처 규칙(Network는 Data 계층에서만 참조되어야 함)을 위반합니다. Domain 계층은 DataInterface 프로토콜을 통해서만 Data 계층과 상호작용해야 합니다. 테스트 시에는 DataInterface를 준수하는 Mock/Stub 객체를 사용하여 의존성을 주입해야 합니다.

APIEndpoint가 포함된 Network 또는 Data 계층의 모듈에 대한 직접적인 의존성은 Domain 계층에서 제거되어야 합니다. 이 테스트는 ClassRepositoryInterface와 같은 DomainInterface에 정의된 프로토콜을 사용하고, 해당 프로토콜의 구현체(예: ClassRepositoryImpl)가 APIEndpoint를 사용하는 형태로 이루어져야 합니다.

@Roy-wonji

Copy link
Copy Markdown
Contributor Author

리뷰 확인했습니다. ClassDomain/Project.swift의 본 타깃과 테스트 타깃 모두 이미 APIEndpoint를 직접 의존하고 있고, ClassRepositoryImpl+*.swift도 해당 서비스 타입을 사용합니다. 이번 PR은 이동된 서비스 타입을 검증하는 기존 계약 테스트의 import를 현재 모듈 경계에 맞춘 변경입니다. API 테스트를 프로토콜 mock으로 바꾸면 HTTP 경로와 요청 본문 검증이 사라지므로 유지합니다.

FeedbackUseCaseStub은 불변 클로저를 가진 값 타입이므로 struct로 유지합니다. final은 클래스에만 적용할 수 있고, 이 테스트에서 참조 의미론은 필요하지 않습니다. ClassDomain 전체 테스트는 Picke-Preview-375에서 통과했습니다.

@Roy-wonji
Roy-wonji merged commit 346cb9e into develop Oct 26, 2026
5 checks passed
@Roy-wonji
Roy-wonji deleted the feature/class-api-contract-tests-20261026 branch October 26, 2026 06:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant