Skip to content

Commit c6bb085

Browse files
committed
Add insta testing, particularly private assets (outside of git repo)
1 parent 7917a6f commit c6bb085

6 files changed

Lines changed: 102 additions & 12 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
/target
22
.idea
3+
/tests/assets/private/**/*
4+
/tests/snapshots/private/**/*

Cargo.lock

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

Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ nu-protocol = { version = "0.107.0", features = ["plugin"] }
2828
nu-plugin-test-support = "0.107.0"
2929
nu-command = "0.107.0"
3030
test-case = "3"
31+
insta = { version = "1.43", default-features = false, features = ["glob", "ron"] }
32+
33+
[profile.dev.package]
34+
insta.opt-level = 3
35+
similar.opt-level = 3
3136

3237
[profile.release]
3338
lto = true

tests/assets/private/.empty

Whitespace-only changes.

tests/dcm_parser_insta.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
use crate::test_utils::get_asset_base_path;
2+
use insta::{assert_ron_snapshot, glob};
3+
use nu_protocol::Span;
4+
use test_utils::setup_plugin_for_test;
5+
6+
mod test_utils;
7+
8+
#[test]
9+
fn private_assets() -> Result<(), nu_protocol::ShellError> {
10+
let mut plugin_test = setup_plugin_for_test(vec![Box::new(nu_command::Open)])?;
11+
let asset_path = get_asset_base_path().join("private");
12+
13+
glob!(asset_path, "**/*.dcm", |path| {
14+
let command = format!("open --raw {} | dcm", path.to_string_lossy());
15+
16+
let result = plugin_test
17+
.eval(&command)
18+
.expect("failed to evaluate command")
19+
.into_value(Span::test_data())
20+
.expect("failed to convert to value");
21+
22+
insta::with_settings!({sort_maps => true, snapshot_path => "snapshots/private" }, {
23+
assert_ron_snapshot!(result);
24+
});
25+
});
26+
27+
Ok(())
28+
}

tests/snapshots/private/.empty

Whitespace-only changes.

0 commit comments

Comments
 (0)