Skip to content

Commit 3362fbc

Browse files
committed
refactor: Change pub to pub(crate) for file_manager module items
1 parent b871643 commit 3362fbc

File tree

4 files changed

+20
-20
lines changed

4 files changed

+20
-20
lines changed

src/file_manager/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
pub mod handlers;
2-
pub mod models;
1+
mod handlers;
2+
mod models;
33

4-
pub use handlers::*;
4+
pub(crate) use handlers::*;
55
pub use models::*;

tests/file_manager/handlers.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ use tokio::fs;
44
struct TestSetup {
55
problem_id: u32,
66
file_content: Vec<u8>,
7-
file_name: String,
7+
filename: String,
88
multipart_body: String,
99
port: u16,
1010
}
1111

12-
async fn setup_test(problem_id: u32, file_content: &[u8], file_name: &str) -> TestSetup {
12+
async fn setup_test(problem_id: u32, file_content: &[u8], filename: &str) -> TestSetup {
1313
// 테스트용 디렉토리만 정리 (uploads 전체가 아닌 특정 problem_id만)
1414
let test_upload_dir = format!("uploads/{}", problem_id);
1515
if Path::new(&test_upload_dir).exists() {
@@ -18,7 +18,7 @@ async fn setup_test(problem_id: u32, file_content: &[u8], file_name: &str) -> Te
1818

1919
let multipart_body = format!(
2020
"--boundary\r\n\
21-
Content-Disposition: form-data; name=\"file\"; filename=\"{file_name}\"\r\n\
21+
Content-Disposition: form-data; name=\"file\"; filename=\"{filename}\"\r\n\
2222
Content-Type: text/plain\r\n\r\n\
2323
{}\r\n\
2424
--boundary--\r\n",
@@ -38,7 +38,7 @@ async fn setup_test(problem_id: u32, file_content: &[u8], file_name: &str) -> Te
3838
TestSetup {
3939
problem_id,
4040
file_content: file_content.to_vec(),
41-
file_name: file_name.to_string(),
41+
filename: filename.to_string(),
4242
multipart_body,
4343
port,
4444
}
@@ -81,14 +81,14 @@ async fn upload_file_success() {
8181
.json::<coduck_backend::file_manager::FileMetadata>()
8282
.await
8383
.unwrap();
84-
assert_eq!(response_json.filename, setup.file_name);
84+
assert_eq!(response_json.filename, setup.filename);
8585
assert_eq!(
8686
response_json.language,
8787
coduck_backend::file_manager::Language::Python
8888
);
8989
assert_eq!(response_json.category, "solution");
9090

91-
let expected_file_path = format!("uploads/{}/solution/{}", setup.problem_id, setup.file_name);
91+
let expected_file_path = format!("uploads/{}/solution/{}", setup.problem_id, setup.filename);
9292
assert!(Path::new(&expected_file_path).exists());
9393

9494
let saved_content = fs::read(&expected_file_path).await.unwrap();
@@ -119,7 +119,7 @@ async fn upload_file_handles_duplicate_filename() {
119119
.contains("already exists"));
120120

121121
// 파일이 실제로 하나만 존재하는지 확인
122-
let expected_file_path = format!("uploads/{}/solution/{}", setup.problem_id, setup.file_name);
122+
let expected_file_path = format!("uploads/{}/solution/{}", setup.problem_id, setup.filename);
123123
assert!(Path::new(&expected_file_path).exists());
124124

125125
cleanup_test(setup.problem_id).await;
@@ -140,7 +140,7 @@ async fn get_file_success() {
140140
"http://127.0.0.1:{port}/problems/{problem_id}/solution/{filename}",
141141
port = setup.port,
142142
problem_id = setup.problem_id,
143-
filename = setup.file_name
143+
filename = setup.filename
144144
))
145145
.send()
146146
.await
@@ -189,7 +189,7 @@ async fn get_files_by_category_success() {
189189
let files: Vec<String> = response.json().await.unwrap();
190190

191191
assert_eq!(files.len(), 1);
192-
assert_eq!(files[0], setup.file_name);
192+
assert_eq!(files[0], setup.filename);
193193

194194
cleanup_test(setup.problem_id).await;
195195
}
@@ -203,7 +203,7 @@ async fn delete_file_success() {
203203
assert_eq!(upload_response.status(), reqwest::StatusCode::CREATED);
204204

205205
// 파일이 존재하는지 확인
206-
let expected_file_path = format!("uploads/{}/solution/{}", setup.problem_id, setup.file_name);
206+
let expected_file_path = format!("uploads/{}/solution/{}", setup.problem_id, setup.filename);
207207
assert!(Path::new(&expected_file_path).exists());
208208

209209
// 파일 삭제
@@ -213,7 +213,7 @@ async fn delete_file_success() {
213213
"http://127.0.0.1:{port}/problems/{problem_id}/solution/{filename}",
214214
port = setup.port,
215215
problem_id = setup.problem_id,
216-
filename = setup.file_name
216+
filename = setup.filename
217217
))
218218
.send()
219219
.await
@@ -282,7 +282,7 @@ async fn update_file_content_success() {
282282
"http://127.0.0.1:{port}/problems/{problem_id}/solution/{filename}",
283283
port = setup.port,
284284
problem_id = setup.problem_id,
285-
filename = setup.file_name
285+
filename = setup.filename
286286
))
287287
.json(&update_data)
288288
.send()
@@ -299,7 +299,7 @@ async fn update_file_content_success() {
299299
.contains("updated successfully"));
300300

301301
// 파일 내용이 실제로 업데이트되었는지 확인
302-
let expected_file_path = format!("uploads/{}/solution/{}", setup.problem_id, setup.file_name);
302+
let expected_file_path = format!("uploads/{}/solution/{}", setup.problem_id, setup.filename);
303303
let updated_content = fs::read_to_string(&expected_file_path).await.unwrap();
304304
assert_eq!(updated_content, "print(int(input()) + int(input()))");
305305

@@ -364,7 +364,7 @@ async fn update_file_missing_content() {
364364
"http://127.0.0.1:{port}/problems/{problem_id}/solution/{filename}",
365365
port = setup.port,
366366
problem_id = setup.problem_id,
367-
filename = setup.file_name
367+
filename = setup.filename
368368
))
369369
.json(&update_data)
370370
.send()
@@ -387,7 +387,7 @@ async fn update_file_filename_success() {
387387
let client = reqwest::Client::new();
388388
let new_filename = "aplusb-AC.py";
389389
let update_data = serde_json::json!({
390-
"old_filename": setup.file_name,
390+
"old_filename": setup.filename,
391391
"new_filename": new_filename
392392
});
393393

tests/file_manager/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
pub mod handlers;
1+
mod handlers;

tests/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
pub mod file_manager;
1+
mod file_manager;

0 commit comments

Comments
 (0)