Skip to content

Commit 77de6e5

Browse files
committed
Clean up test includes for File and Path
1 parent 8c867a0 commit 77de6e5

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

src/exercise.rs

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
use serde::Deserialize;
12
use std::fmt::{self, Display, Formatter};
23
use std::fs::{remove_file};
34
use std::path::{PathBuf};
45
use std::process::{self, Command, Output};
5-
use serde::Deserialize;
66

77
const RUSTC_COLOR_ARGS: &[&str] = &["--color", "always"];
88

@@ -60,13 +60,20 @@ impl Display for Exercise {
6060
}
6161
}
6262

63-
#[test]
64-
fn test_clean() {
65-
std::fs::File::create(&temp_file()).unwrap();
66-
let exercise = Exercise {
67-
path: PathBuf::from("example.rs"),
68-
mode: Mode::Test,
69-
};
70-
exercise.clean();
71-
assert!(!std::path::Path::new(&temp_file()).exists());
63+
#[cfg(test)]
64+
mod test {
65+
use super::*;
66+
use std::path::Path;
67+
use std::fs::File;
68+
69+
#[test]
70+
fn test_clean() {
71+
File::create(&temp_file()).unwrap();
72+
let exercise = Exercise {
73+
path: PathBuf::from("example.rs"),
74+
mode: Mode::Test,
75+
};
76+
exercise.clean();
77+
assert!(!Path::new(&temp_file()).exists());
78+
}
7279
}

0 commit comments

Comments
 (0)