forked from mitsuhiko/insta
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_glob.rs
35 lines (30 loc) · 846 Bytes
/
test_glob.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#![cfg(feature = "glob")]
mod glob_submodule;
#[test]
fn test_basic_globbing() {
insta::glob!("inputs/*.txt", |path| {
let contents = std::fs::read_to_string(path).unwrap();
insta::assert_json_snapshot!(&contents);
});
}
#[test]
fn test_basic_globbing_nested() {
insta::glob!("inputs-nested/*/*.txt", |path| {
let contents = std::fs::read_to_string(path).unwrap();
insta::assert_snapshot!(&contents);
});
}
#[test]
fn test_globs_follow_links() {
insta::glob!("link-to-inputs/*.txt", |path| {
let contents = std::fs::read_to_string(path).unwrap();
insta::assert_json_snapshot!(&contents);
});
}
#[test]
#[should_panic(expected = "the glob! macro did not match any files.")]
fn test_empty_glob_fails() {
insta::glob!("nonexistent", |_| {
// nothing
});
}