-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create a fixture from files
attribute
#233
Comments
Sorry, but I cannot understand what you want to do... can you write an example that show what you want to do? |
I want to use the Here's an example: Right now I will have to do all this part every time I want to use a HashMap of the struct. I guess I could create a a singular fixture that returns a HashMap<PathBuf,HashMap<StorePathRef,NarInfo> or whatever, but I think having multiple fixtures make more sense, sort of like a matrix. |
Ok, maybe a good syntax could be something like: fn nar_info(path: PathBuf) -> HashMap<String, Closure> {
let attrs_file = File::open(path).unwrap();
let reader = BufReader::new(attrs_file);
let attrs: Attrs = serde_json::from_reader(reader).unwrap();
attrs
.closure
.iter()
.map(|c| {
let c = c.to_narinfo().unwrap();
(c.store_path, c)
})
.collect()
}
#[rstest]
fn all_references_uploaded(#[files("src/fixtures/*.json")] #[map(nar_infos)] nar_infos: HashMap<String, Closure>) {
let all_references = nar_infos
.values()
.flat_map(|x| x.references.clone())
.collect::<HashSet<_>>();
let uploaded = do_work(make_work(nar_infos));
assert_eq!(all_references, uploaded);
} where |
I want to be able to create a fixture by reusing the
files
attribute logic from therstest
attribute.The text was updated successfully, but these errors were encountered: