Skip to content

Commit dc9746a

Browse files
committed
fixed test
1 parent 51d5f78 commit dc9746a

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

tmc-langs-cli/src/config/projects_config.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ impl ProjectsConfig {
5252
&exercise_name,
5353
);
5454
if !expected_dir.exists() {
55+
log::debug!(
56+
"local exercise {} not found, deleting from config",
57+
expected_dir.display()
58+
);
5559
deleted_exercises.push(exercise_name.clone());
5660
}
5761
}
@@ -133,7 +137,7 @@ mod test {
133137
std::fs::write(target, contents.as_ref()).unwrap();
134138
}
135139

136-
fn _dir_to(temp: impl AsRef<std::path::Path>, relative_path: impl AsRef<std::path::Path>) {
140+
fn dir_to(temp: impl AsRef<std::path::Path>, relative_path: impl AsRef<std::path::Path>) {
137141
let target = temp.as_ref().join(relative_path);
138142
std::fs::create_dir_all(target).unwrap();
139143
}
@@ -191,7 +195,7 @@ checksum = "bcde2345"
191195
let temp = tempfile::TempDir::new().unwrap();
192196
file_to(
193197
&temp,
194-
"course 1/course_config.toml",
198+
"python/course_config.toml",
195199
r#"
196200
course = "python"
197201
@@ -204,9 +208,11 @@ id = 5432
204208
checksum = "bcde2345"
205209
"#,
206210
);
211+
dir_to(&temp, "python/ex1");
212+
dir_to(&temp, "python/ex 2");
207213
file_to(
208214
&temp,
209-
"course 2/course_config.toml",
215+
"java/course_config.toml",
210216
r#"
211217
course = "java"
212218
@@ -219,11 +225,13 @@ id = 7654
219225
checksum = "defg4567"
220226
"#,
221227
);
228+
dir_to(&temp, "java/ex3");
229+
dir_to(&temp, "java/ex 4");
222230

223231
let mut pc = ProjectsConfig::load(temp.path()).unwrap();
224232
assert_eq!(pc.courses.len(), 2);
225233

226-
let mut cc = pc.courses.remove("course 1").unwrap();
234+
let mut cc = pc.courses.remove("python").unwrap();
227235
assert_eq!(cc.course, "python");
228236
assert_eq!(cc.exercises.len(), 2);
229237
let ex = cc.exercises.remove("ex1").unwrap();
@@ -233,7 +241,7 @@ checksum = "defg4567"
233241
assert_eq!(ex.id, 5432);
234242
assert_eq!(ex.checksum, "bcde2345");
235243

236-
let mut cc = pc.courses.remove("course 2").unwrap();
244+
let mut cc = pc.courses.remove("java").unwrap();
237245
assert_eq!(cc.course, "java");
238246
assert_eq!(cc.exercises.len(), 2);
239247
let ex = cc.exercises.remove("ex3").unwrap();

0 commit comments

Comments
 (0)