Skip to content

Commit 850d59d

Browse files
committed
add test
Signed-off-by: scepter914 <scepter914@gmail.com>
1 parent cdc27ac commit 850d59d

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

tests/test_project.rs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,43 @@ use predicates::prelude::*;
33
use std::fs;
44
use tempfile::tempdir;
55

6+
#[test]
7+
fn test_init() {
8+
let temp_dir = tempdir().unwrap();
9+
10+
let mut cmd = cargo_bin_cmd!("ml-cellar");
11+
cmd.arg("init");
12+
cmd.current_dir(temp_dir.path());
13+
cmd.assert().success();
14+
15+
// Check .gitattributes
16+
let gitattributes_path = temp_dir.path().join(".gitattributes");
17+
assert!(gitattributes_path.is_file(), ".gitattributes should exist");
18+
19+
let gitattributes_text = fs::read_to_string(&gitattributes_path).unwrap();
20+
let target_gitattributes = fs::read_to_string("tests/fixtures/.gitattributes").unwrap();
21+
assert!(
22+
gitattributes_text == target_gitattributes,
23+
".gitattributes is \n***\n{} \n*** \n and different from the target file.",
24+
gitattributes_text
25+
);
26+
27+
// Check .mlcellar.toml
28+
let repository_config_path = temp_dir.path().join(".mlcellar.toml");
29+
assert!(
30+
repository_config_path.is_file(),
31+
".mlcellar.toml should exist"
32+
);
33+
34+
let mlcellar_text = fs::read_to_string(&repository_config_path).unwrap();
35+
let target_mlcellar = fs::read_to_string("tests/fixtures/.mlcellar.toml").unwrap();
36+
assert!(
37+
mlcellar_text == target_mlcellar,
38+
".mlcellar.toml is \n***\n{} \n*** \n and different from the target file.",
39+
mlcellar_text
40+
);
41+
}
42+
643
#[test]
744
fn test_project() {
845
let temp_dir = tempdir().unwrap();

0 commit comments

Comments
 (0)