|
| 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 | +} |
| 38 | + |
| 39 | +#[test] |
| 40 | +fn js_highlight_panics() { |
| 41 | + let root = snapbox::path::PathFixture::mutable_temp().unwrap(); |
| 42 | + let root_path = root.path().unwrap(); |
| 43 | + let plan = git_fixture::TodoList { |
| 44 | + commands: vec![ |
| 45 | + git_fixture::Command::Tree(git_fixture::Tree { |
| 46 | + files: [("basic.js", "test('arg1');")] |
| 47 | + .into_iter() |
| 48 | + .map(|(p, c)| (p.into(), c.into())) |
| 49 | + .collect::<std::collections::HashMap<_, _>>(), |
| 50 | + message: Some("A".to_owned()), |
| 51 | + author: None, |
| 52 | + }), |
| 53 | + git_fixture::Command::Branch("main".into()), |
| 54 | + ], |
| 55 | + ..Default::default() |
| 56 | + }; |
| 57 | + plan.run(root_path).unwrap(); |
| 58 | + |
| 59 | + snapbox::cmd::Command::new(snapbox::cmd::cargo_bin!("git-dive")) |
| 60 | + .arg("basic.js") |
| 61 | + .current_dir(root_path) |
| 62 | + .env("CLICOLOR_FORCE", "1") |
| 63 | + .assert() |
| 64 | + .success() |
| 65 | + .stderr_matches( |
| 66 | + "\ |
| 67 | +", |
| 68 | + ); |
| 69 | + |
| 70 | + root.close().unwrap(); |
| 71 | +} |
0 commit comments