Skip to content

Conversation

@reddevilmidzy
Copy link
Member

@reddevilmidzy reddevilmidzy commented Sep 20, 2025

구현한 기능

  • tempfile 사용하여 테스트 종료시 자동으로 테스트 시 생성한 디렉터리 삭제
  • .env에 파일 업로드할 경로 설정
  • src/file_manager/handlers.rs에 있던 비즈니스 로직을 src/file_manager/storage.rssrc/file_manager/service.rs를 만들어 분리

#47 TODO에서 test와 production 환경 분리 작업과 tempfile crate 사용하여 테스트 보완 작업을 하였습니다.

part of #40


TODO

  • 사용자마다 다른 branch를 생성
  • 리비전 확인, 커밋 하기 등 API 만들기 (현재 로직은 구현됐으나 활용하는 코드는 구현되지 않음)
  • file_manager/service.rs 에서 예외 발생시 에러 원인 포함한 String을 handlers.rs로 전달하고 handlers.rs에서 String을 확인하여 에러 파악하고 HTTP 상태코드 반환하는데, 이를 String이 아닌 enum으로 변경하기

- Replace per-request service creation with dependency injection
- Add .env support for UPLOAD_DIR configuration
- Implement sequential test execution to prevent race conditions
- Auto-generate test problem IDs using rand
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR improves the test architecture and adds environment configuration by implementing proper test isolation with automatic cleanup, introducing configurable file upload paths, and restructuring the codebase to separate business logic from handlers.

  • Uses tempfile crate for automatic test directory cleanup upon test completion
  • Adds environment variable configuration for upload directory paths via .env file
  • Refactors file management architecture by separating storage layer (LocalFileStorage), service layer (FileService), and handlers

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/file_manager/handlers.rs Replaces manual cleanup with tempfile-based test isolation and adds serial test execution
src/lib.rs Adds environment configuration loading and dependency injection for file service
src/file_manager/storage.rs New storage abstraction layer for file operations
src/file_manager/service.rs New service layer containing business logic for file operations
src/file_manager/mod.rs Exports new storage and service modules
src/file_manager/handlers.rs Refactored to use dependency injection and simplified error handling
src/file_manager/git.rs Updated to use configurable base paths instead of hardcoded directory
Cargo.toml Adds dependencies for environment configuration, random number generation, and test utilities
.env Adds upload directory configuration

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@w8385
Copy link
Member

w8385 commented Sep 21, 2025

random으로 problem_id 생성하는 건 테스트간 단순 충돌 방지 목적인가요?

@reddevilmidzy
Copy link
Member Author

reddevilmidzy commented Sep 21, 2025

random으로 problem_id 생성하는 건 테스트간 단순 충돌 방지 목적인가요?

생각해보니 이제 테스트마다 저장되는 디렉터리가 달라져서 굳이 이악물고 rand crate 사용해서 랜덤으로 만들 필요도 없는것 같네요👍

고냥 problem_id = 0으로 변경하겠습니다

@reddevilmidzy
Copy link
Member Author

이 PR은 일단 merge하고 request change 있으면 40-revision 에서 main 갈 때 반영하겠습니다!
@utilForever

@reddevilmidzy reddevilmidzy merged commit ba52656 into 40-revision Oct 10, 2025
4 checks passed
@reddevilmidzy reddevilmidzy deleted the 40-revision-env branch October 10, 2025 12:59
@reddevilmidzy
Copy link
Member Author

dotenv 말고 다른 걸 사용해야 겠군요
https://github.com/Coduck-Team/coduck-backend/actions/runs/18407241101/job/52450578907

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.

3 participants