Skip to content

Commit 96f8517

Browse files
committed
test(mdman): Switch to snapbox
- We use it elsewhere - We don't have to bake our own snapshotting solution - It is more obvious how to update the snapshots
1 parent bbd2dcd commit 96f8517

File tree

5 files changed

+7
-42
lines changed

5 files changed

+7
-42
lines changed

Cargo.lock

Lines changed: 1 addition & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ pasetors = { version = "0.6.7", features = ["v3", "paserk", "std", "serde"] }
6969
pathdiff = "0.2"
7070
percent-encoding = "2.3"
7171
pkg-config = "0.3.27"
72-
pretty_assertions = "1.4.0"
7372
proptest = "1.4.0"
7473
pulldown-cmark = { version = "0.9.3", default-features = false }
7574
rand = "0.8.5"

crates/mdman/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ serde_json.workspace = true
1616
url.workspace = true
1717

1818
[dev-dependencies]
19-
pretty_assertions.workspace = true
19+
snapbox.workspace = true
2020

2121
[lints]
2222
workspace = true

crates/mdman/tests/compare.rs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
//! Compares input to expected output.
2-
//!
3-
//! Use the MDMAN_BLESS environment variable to automatically update the
4-
//! expected output.
52
6-
#![allow(clippy::disallowed_methods)]
3+
use std::path::PathBuf;
74

85
use mdman::{Format, ManMap};
9-
use pretty_assertions::assert_eq;
10-
use std::path::PathBuf;
116
use url::Url;
127

138
fn run(name: &str) {
@@ -27,14 +22,7 @@ fn run(name: &str) {
2722
name,
2823
format.extension(section)
2924
);
30-
if std::env::var("MDMAN_BLESS").is_ok() {
31-
std::fs::write(&expected_path, result).unwrap();
32-
} else {
33-
let expected = std::fs::read_to_string(&expected_path).unwrap();
34-
// Fix if Windows checked out with autocrlf.
35-
let expected = expected.replace("\r\n", "\n");
36-
assert_eq!(expected, result);
37-
}
25+
snapbox::assert_eq_path(expected_path, result);
3826
}
3927
}
4028

crates/mdman/tests/invalid.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
//! Tests for errors and invalid input.
22
3-
use mdman::{Format, ManMap};
4-
use pretty_assertions::assert_eq;
53
use std::path::PathBuf;
64

5+
use mdman::{Format, ManMap};
6+
77
fn run(name: &str, expected_error: &str) {
88
let input = PathBuf::from(format!("tests/invalid/{}", name));
99
match mdman::convert(&input, Format::Man, None, ManMap::new()) {
1010
Ok(_) => {
1111
panic!("expected {} to fail", name);
1212
}
1313
Err(e) => {
14-
assert_eq!(expected_error, e.to_string());
14+
snapbox::assert_eq(expected_error, e.to_string());
1515
}
1616
}
1717
}

0 commit comments

Comments
 (0)