Use playground instead of depending on fixture format files. (#1726)

This commit is contained in:
Andrés N. Robalino 2020-05-07 06:58:35 -05:00 committed by GitHub
parent 96e5fc05a3
commit 180c1204f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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
}
]
);
})
}
}