40 lines
987 B
Rust
40 lines
987 B
Rust
type TestResult = Result<(), Box<dyn std::error::Error>>;
|
|
|
|
mod init {
|
|
use super::*;
|
|
#[test]
|
|
fn should_not_update_file_if_it_exists() -> TestResult {
|
|
let fs = kxio::fs::temp()?;
|
|
let file = fs.base().join(".git-next.toml");
|
|
fs.file_write(&file, "contents")?;
|
|
|
|
crate::init::run(fs.clone());
|
|
|
|
assert_eq!(
|
|
fs.file_read_to_string(&file)?,
|
|
"contents",
|
|
"The file has been changed"
|
|
);
|
|
|
|
Ok(())
|
|
}
|
|
|
|
#[test]
|
|
fn should_create_default_file_if_not_exists() -> TestResult {
|
|
let fs = kxio::fs::temp()?;
|
|
|
|
crate::init::run(fs.clone());
|
|
|
|
let file = fs.base().join(".git-next.toml");
|
|
|
|
assert!(fs.path_exists(&file)?, "The file has not been created");
|
|
|
|
assert_eq!(
|
|
fs.file_read_to_string(&file)?,
|
|
include_str!("../../../default.toml"),
|
|
"The file does not match the default template"
|
|
);
|
|
|
|
Ok(())
|
|
}
|
|
}
|