mirror of
https://github.com/nushell/nushell.git
synced 2024-11-25 01:43:47 +01:00
Use playground instead of depending on fixture format files. (#1726)
This commit is contained in:
parent
96e5fc05a3
commit
180c1204f3
@ -171,14 +171,9 @@ mod tests {
|
||||
use super::{FileStructure, Res, ValueResource, ValueStructure};
|
||||
use nu_protocol::{TaggedDictBuilder, UntaggedValue, Value};
|
||||
use nu_source::Tag;
|
||||
use nu_test_support::fs;
|
||||
use nu_test_support::{fs::Stub::EmptyFile, playground::Playground};
|
||||
use std::path::PathBuf;
|
||||
|
||||
fn fixtures() -> PathBuf {
|
||||
let fixtures = fs::fixtures().join("formats");
|
||||
dunce::canonicalize(fixtures).expect("Wrong path")
|
||||
}
|
||||
|
||||
fn structured_sample_record(key: &str, value: &str) -> Value {
|
||||
let mut record = TaggedDictBuilder::new(Tag::unknown());
|
||||
record.insert_untagged(key, UntaggedValue::string(value));
|
||||
@ -265,83 +260,35 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn prepares_and_decorates_filesystem_source_files() {
|
||||
Playground::setup("file_structure_test", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![
|
||||
EmptyFile("sample.ini"),
|
||||
EmptyFile("sample.eml"),
|
||||
EmptyFile("cargo_sample.toml"),
|
||||
]);
|
||||
|
||||
let mut res = FileStructure::new();
|
||||
|
||||
res.walk_decorate(&fixtures())
|
||||
res.walk_decorate(&dirs.test())
|
||||
.expect("Can not decorate files traversal.");
|
||||
|
||||
assert_eq!(
|
||||
res.resources,
|
||||
vec![
|
||||
Res {
|
||||
loc: fixtures().join("appveyor.yml"),
|
||||
loc: dirs.test().join("cargo_sample.toml"),
|
||||
at: 0
|
||||
},
|
||||
Res {
|
||||
loc: fixtures().join("caco3_plastics.csv"),
|
||||
loc: dirs.test().join("sample.eml"),
|
||||
at: 0
|
||||
},
|
||||
Res {
|
||||
loc: fixtures().join("caco3_plastics.tsv"),
|
||||
at: 0
|
||||
},
|
||||
Res {
|
||||
loc: fixtures().join("cargo_sample.toml"),
|
||||
at: 0
|
||||
},
|
||||
Res {
|
||||
loc: fixtures().join("jonathan.xml"),
|
||||
at: 0
|
||||
},
|
||||
Res {
|
||||
loc: fixtures().join("sample.bson"),
|
||||
at: 0
|
||||
},
|
||||
Res {
|
||||
loc: fixtures().join("sample.db"),
|
||||
at: 0
|
||||
},
|
||||
Res {
|
||||
loc: fixtures().join("sample.eml"),
|
||||
at: 0
|
||||
},
|
||||
Res {
|
||||
loc: fixtures().join("sample.ini"),
|
||||
at: 0
|
||||
},
|
||||
Res {
|
||||
loc: fixtures().join("sample.url"),
|
||||
at: 0
|
||||
},
|
||||
Res {
|
||||
loc: fixtures().join("sample_data.ods"),
|
||||
at: 0
|
||||
},
|
||||
Res {
|
||||
loc: fixtures().join("sample_data.xlsx"),
|
||||
at: 0
|
||||
},
|
||||
Res {
|
||||
loc: fixtures().join("sample_headers.xlsx"),
|
||||
at: 0
|
||||
},
|
||||
Res {
|
||||
loc: fixtures().join("script.nu"),
|
||||
at: 0
|
||||
},
|
||||
Res {
|
||||
loc: fixtures().join("script_multiline.nu"),
|
||||
at: 0
|
||||
},
|
||||
Res {
|
||||
loc: fixtures().join("sgml_description.json"),
|
||||
at: 0
|
||||
},
|
||||
Res {
|
||||
loc: fixtures().join("utf16.ini"),
|
||||
loc: dirs.test().join("sample.ini"),
|
||||
at: 0
|
||||
}
|
||||
]
|
||||
);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user