Skip to content

Commit e6b045d

Browse files
committed
test: Add basic test
1 parent 79eeeb2 commit e6b045d

File tree

3 files changed

+136
-3
lines changed

3 files changed

+136
-3
lines changed

Cargo.lock

Lines changed: 98 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ bugreport = "0.5.0"
5858
dunce = "1.0.3"
5959

6060
[dev-dependencies]
61+
git-fixture = "0.3.1"
6162
snapbox = { version = "0.4.10", features = ["path"] }
6263
term-transcript = "0.2.0"
6364

tests/cli.rs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#[test]
2+
fn basic() {
3+
let root = snapbox::path::PathFixture::mutable_temp().unwrap();
4+
let root_path = root.path().unwrap();
5+
let plan = git_fixture::TodoList {
6+
commands: vec![
7+
git_fixture::Command::Tree(git_fixture::Tree {
8+
files: [("basic.js", "test('arg1');")]
9+
.into_iter()
10+
.map(|(p, c)| (p.into(), c.into()))
11+
.collect::<std::collections::HashMap<_, _>>(),
12+
message: Some("A".to_owned()),
13+
author: None,
14+
}),
15+
git_fixture::Command::Branch("main".into()),
16+
],
17+
..Default::default()
18+
};
19+
plan.run(root_path).unwrap();
20+
21+
snapbox::cmd::Command::new(snapbox::cmd::cargo_bin!("git-dive"))
22+
.arg("basic.js")
23+
.current_dir(root_path)
24+
.assert()
25+
.success()
26+
.stdout_eq(
27+
"\
28+
HEAD 1 │ test('arg1');
29+
",
30+
)
31+
.stderr_matches(
32+
"\
33+
",
34+
);
35+
36+
root.close().unwrap();
37+
}

0 commit comments

Comments
 (0)