mirror of
https://github.com/nushell/nushell
synced 2024-12-25 04:23:10 +00:00
Use playground instead of depending on fixture format files. (#1726)
This commit is contained in:
parent
96e5fc05a3
commit
180c1204f3
1 changed files with 29 additions and 82 deletions
|
@ -171,14 +171,9 @@ mod tests {
|
||||||
use super::{FileStructure, Res, ValueResource, ValueStructure};
|
use super::{FileStructure, Res, ValueResource, ValueStructure};
|
||||||
use nu_protocol::{TaggedDictBuilder, UntaggedValue, Value};
|
use nu_protocol::{TaggedDictBuilder, UntaggedValue, Value};
|
||||||
use nu_source::Tag;
|
use nu_source::Tag;
|
||||||
use nu_test_support::fs;
|
use nu_test_support::{fs::Stub::EmptyFile, playground::Playground};
|
||||||
use std::path::PathBuf;
|
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 {
|
fn structured_sample_record(key: &str, value: &str) -> Value {
|
||||||
let mut record = TaggedDictBuilder::new(Tag::unknown());
|
let mut record = TaggedDictBuilder::new(Tag::unknown());
|
||||||
record.insert_untagged(key, UntaggedValue::string(value));
|
record.insert_untagged(key, UntaggedValue::string(value));
|
||||||
|
@ -265,83 +260,35 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn prepares_and_decorates_filesystem_source_files() {
|
fn prepares_and_decorates_filesystem_source_files() {
|
||||||
let mut res = FileStructure::new();
|
Playground::setup("file_structure_test", |dirs, sandbox| {
|
||||||
|
sandbox.with_files(vec![
|
||||||
|
EmptyFile("sample.ini"),
|
||||||
|
EmptyFile("sample.eml"),
|
||||||
|
EmptyFile("cargo_sample.toml"),
|
||||||
|
]);
|
||||||
|
|
||||||
res.walk_decorate(&fixtures())
|
let mut res = FileStructure::new();
|
||||||
.expect("Can not decorate files traversal.");
|
|
||||||
|
|
||||||
assert_eq!(
|
res.walk_decorate(&dirs.test())
|
||||||
res.resources,
|
.expect("Can not decorate files traversal.");
|
||||||
vec![
|
|
||||||
Res {
|
assert_eq!(
|
||||||
loc: fixtures().join("appveyor.yml"),
|
res.resources,
|
||||||
at: 0
|
vec![
|
||||||
},
|
Res {
|
||||||
Res {
|
loc: dirs.test().join("cargo_sample.toml"),
|
||||||
loc: fixtures().join("caco3_plastics.csv"),
|
at: 0
|
||||||
at: 0
|
},
|
||||||
},
|
Res {
|
||||||
Res {
|
loc: dirs.test().join("sample.eml"),
|
||||||
loc: fixtures().join("caco3_plastics.tsv"),
|
at: 0
|
||||||
at: 0
|
},
|
||||||
},
|
Res {
|
||||||
Res {
|
loc: dirs.test().join("sample.ini"),
|
||||||
loc: fixtures().join("cargo_sample.toml"),
|
at: 0
|
||||||
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"),
|
|
||||||
at: 0
|
|
||||||
}
|
|
||||||
]
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue