-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use rstest to generate tests from fixtures
- Loading branch information
Showing
3 changed files
with
47 additions
and
30 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,15 @@ | ||
use core::panic; | ||
|
||
use rust_embed::Embed; | ||
|
||
#[derive(Embed)] | ||
#[folder = "tests/actors"] | ||
struct Actors; | ||
|
||
#[derive(Embed)] | ||
#[folder = "tests/objects"] | ||
struct Objects; | ||
|
||
#[test] | ||
fn actors() { | ||
for actor_path in Actors::iter() { | ||
let file = Actors::get(&actor_path).unwrap(); | ||
if let Err(error) = sonic_rs::from_slice::<kitsune_type::ap::actor::Actor>(&file.data) { | ||
panic!("Failed to deserialize actor at path {actor_path}: {error}"); | ||
} | ||
} | ||
use rstest::rstest; | ||
use std::{fs, path::PathBuf}; | ||
|
||
#[rstest] | ||
fn actors(#[files("tests/actors/*")] path: PathBuf) { | ||
let data = fs::read(path).unwrap(); | ||
sonic_rs::from_slice::<kitsune_type::ap::actor::Actor>(&data) | ||
.expect("Failed to deserialize actor"); | ||
} | ||
|
||
#[test] | ||
fn objects() { | ||
for object_path in Objects::iter() { | ||
let file = Objects::get(&object_path).unwrap(); | ||
if let Err(error) = sonic_rs::from_slice::<kitsune_type::ap::Object>(&file.data) { | ||
panic!("Failed to deserialize object at path {object_path}: {error}"); | ||
} | ||
} | ||
#[rstest] | ||
fn objects(#[files("tests/objects/*")] path: PathBuf) { | ||
let data = fs::read(path).unwrap(); | ||
sonic_rs::from_slice::<kitsune_type::ap::Object>(&data).expect("Failed to deserialize object"); | ||
} |