Skip to content

Commit 3922ebf

Browse files
committed
fix: Update API routes to use plural 'solutions' instead of singular 'solution'
1 parent 25e2df0 commit 3922ebf

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

tests/file_manager/handlers.rs

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ async fn setup_test() -> TestSetup {
3636
async fn upload_file_request(setup: &TestSetup, multipart_body: String) -> reqwest::Response {
3737
reqwest::Client::new()
3838
.post(&format!(
39-
"http://127.0.0.1:{port}/problems/{problem_id}/solution",
39+
"http://127.0.0.1:{port}/problems/{problem_id}/solutions",
4040
port = setup.port,
4141
problem_id = setup.problem_id
4242
))
@@ -90,10 +90,10 @@ async fn upload_file_success() {
9090
response_json.language,
9191
coduck_backend::file_manager::Language::Python
9292
);
93-
assert_eq!(response_json.category, "solution");
93+
assert_eq!(response_json.category, "solutions");
9494

9595
let expected_file_path = format!(
96-
"{}/{}/solution/{}",
96+
"{}/{}/solutions/{}",
9797
setup.temp_dir.path().to_str().unwrap(),
9898
setup.problem_id,
9999
filename
@@ -126,7 +126,7 @@ async fn upload_file_handles_duplicate_filename() {
126126
.contains("already exists"));
127127

128128
let expected_file_path = format!(
129-
"{}/{}/solution/{}",
129+
"{}/{}/solutions/{}",
130130
setup.temp_dir.path().to_str().unwrap(),
131131
setup.problem_id,
132132
filename
@@ -149,7 +149,7 @@ async fn get_file_success() {
149149
let client = reqwest::Client::new();
150150
let response = client
151151
.get(&format!(
152-
"http://127.0.0.1:{port}/problems/{problem_id}/solution/{filename}",
152+
"http://127.0.0.1:{port}/problems/{problem_id}/solutions/{filename}",
153153
port = setup.port,
154154
problem_id = setup.problem_id,
155155
filename = filename
@@ -187,10 +187,9 @@ async fn get_files_by_category_success() {
187187
let client = reqwest::Client::new();
188188
let response = client
189189
.get(&format!(
190-
"http://127.0.0.1:{port}/problems/{problem_id}/{category}",
190+
"http://127.0.0.1:{port}/problems/{problem_id}/solutions",
191191
port = setup.port,
192192
problem_id = setup.problem_id,
193-
category = "solution"
194193
))
195194
.send()
196195
.await
@@ -216,7 +215,7 @@ async fn delete_file_success() {
216215

217216
// Check if file exists
218217
let expected_file_path = format!(
219-
"{}/{}/solution/{}",
218+
"{}/{}/solutions/{}",
220219
setup.temp_dir.path().to_str().unwrap(),
221220
setup.problem_id,
222221
filename
@@ -227,7 +226,7 @@ async fn delete_file_success() {
227226
let client = reqwest::Client::new();
228227
let response = client
229228
.delete(&format!(
230-
"http://127.0.0.1:{port}/problems/{problem_id}/solution/{filename}",
229+
"http://127.0.0.1:{port}/problems/{problem_id}/solutions/{filename}",
231230
port = setup.port,
232231
problem_id = setup.problem_id,
233232
filename = filename
@@ -257,7 +256,7 @@ async fn delete_file_not_found() {
257256
let client = reqwest::Client::new();
258257
let response = client
259258
.delete(&format!(
260-
"http://127.0.0.1:{port}/problems/{problem_id}/solution/{filename}",
259+
"http://127.0.0.1:{port}/problems/{problem_id}/solutions/{filename}",
261260
port = setup.port,
262261
problem_id = setup.problem_id,
263262
filename = "non-existent-file.py"
@@ -295,7 +294,7 @@ async fn update_file_content_success() {
295294

296295
let response = client
297296
.put(&format!(
298-
"http://127.0.0.1:{port}/problems/{problem_id}/solution/{filename}",
297+
"http://127.0.0.1:{port}/problems/{problem_id}/solutions/{filename}",
299298
port = setup.port,
300299
problem_id = setup.problem_id,
301300
filename = filename
@@ -316,7 +315,7 @@ async fn update_file_content_success() {
316315

317316
// Verify that file content was actually updated
318317
let expected_file_path = format!(
319-
"{}/{}/solution/{}",
318+
"{}/{}/solutions/{}",
320319
setup.temp_dir.path().to_str().unwrap(),
321320
setup.problem_id,
322321
filename
@@ -338,7 +337,7 @@ async fn update_file_not_found() {
338337

339338
let response = client
340339
.put(&format!(
341-
"http://127.0.0.1:{port}/problems/{problem_id}/solution/{filename}",
340+
"http://127.0.0.1:{port}/problems/{problem_id}/solutions/{filename}",
342341
port = setup.port,
343342
problem_id = setup.problem_id,
344343
filename = "non-existent-file.py"
@@ -377,7 +376,7 @@ async fn update_file_missing_content() {
377376

378377
let response = client
379378
.put(&format!(
380-
"http://127.0.0.1:{port}/problems/{problem_id}/solution/{filename}",
379+
"http://127.0.0.1:{port}/problems/{problem_id}/solutions/{filename}",
381380
port = setup.port,
382381
problem_id = setup.problem_id,
383382
filename = filename
@@ -412,7 +411,7 @@ async fn update_filename_success() {
412411

413412
let response = client
414413
.put(&format!(
415-
"http://127.0.0.1:{port}/problems/{problem_id}/solution",
414+
"http://127.0.0.1:{port}/problems/{problem_id}/solutions",
416415
port = setup.port,
417416
problem_id = setup.problem_id
418417
))
@@ -432,7 +431,7 @@ async fn update_filename_success() {
432431

433432
// Verify that filename was actually updated
434433
let expected_file_path = format!(
435-
"{}/{}/solution/{}",
434+
"{}/{}/solutions/{}",
436435
setup.temp_dir.path().to_str().unwrap(),
437436
setup.problem_id,
438437
new_filename

0 commit comments

Comments
 (0)