Skip to content

Commit

Permalink
Port crate alias test to new integration test style
Browse files Browse the repository at this point in the history
  • Loading branch information
GREsau committed Sep 8, 2024
1 parent d31a71b commit 4aeda95
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 40 deletions.
20 changes: 0 additions & 20 deletions schemars/tests/crate_alias.rs

This file was deleted.

19 changes: 0 additions & 19 deletions schemars/tests/expected/crate_alias.json

This file was deleted.

19 changes: 19 additions & 0 deletions schemars/tests/integration/crate_alias.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use crate::prelude::*;
use ::schemars as aliased_schemars;

#[allow(dead_code)]
#[derive(aliased_schemars::JsonSchema, Deserialize, Serialize, Default)]
#[schemars(crate = "aliased_schemars")]
struct MyStruct {
/// Is it ok with doc comments?
foo: i32,
#[schemars(extend("x-test" = "...and extensions?"))]
bar: bool,
}

#[test]
fn crate_alias() {
test!(MyStruct)
.assert_allows_ser_roundtrip_default()
.assert_matches_de_roundtrip(arbitrary_values());
}
1 change: 1 addition & 0 deletions schemars/tests/integration/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ mod bytes;
#[cfg(feature = "chrono04")]
mod chrono;
mod contract;
mod crate_alias;

mod prelude {
pub use crate::test;
Expand Down
2 changes: 1 addition & 1 deletion schemars/tests/integration/test_helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ impl<T: JsonSchema + Serialize + for<'de> Deserialize<'de>> TestHelper<T> {

assert!(
T::deserialize(value).is_err(),
"invalid test case - expected deserialize to succeed for {}: {value}",
"invalid test case - expected deserialize to fail for {}: {value}",
type_name::<T>()
);

Expand Down

0 comments on commit 4aeda95

Please sign in to comment.