From 37045344658f716bad6a41afe74b01d914f7e4f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?dj8yf0=CE=BCl?= Date: Mon, 28 Oct 2024 11:11:31 +0200 Subject: [PATCH] ci: add new tests to ci run --- .github/test.sh | 6 + ...ip__test_serde_json_value__json_value.snap | 833 ++++++++++++++++++ ...{test_json.rs => test_serde_json_value.rs} | 4 + borsh/tests/schema/test_serde_json_value.rs | 1 + borsh/tests/tests.rs | 5 +- 5 files changed, 848 insertions(+), 1 deletion(-) create mode 100644 borsh/tests/roundtrip/snapshots/tests__roundtrip__test_serde_json_value__json_value.snap rename borsh/tests/roundtrip/{test_json.rs => test_serde_json_value.rs} (95%) create mode 100644 borsh/tests/schema/test_serde_json_value.rs diff --git a/.github/test.sh b/.github/test.sh index 2fdbf58b9..44610393d 100755 --- a/.github/test.sh +++ b/.github/test.sh @@ -28,6 +28,9 @@ cargo test --features de_strict_order 'roundtrip::test_hash_map' cargo test --features de_strict_order 'roundtrip::test_btree_map' ########## features = ["bson"] group cargo test --features bson,derive 'roundtrip::requires_derive_category::test_bson_object_ids' +########## features = ["serde_json_value"] group +cargo test --features serde_json_value 'roundtrip::test_serde_json_value' +cargo test --features serde_json_value,unstable__schema 'schema::test_serde_json_value' ########## features = ["bytes"] group cargo test --features bytes,derive 'roundtrip::requires_derive_category::test_ultimate_many_features_combined' @@ -44,6 +47,9 @@ cargo test --no-default-features --features ascii,unstable__schema 'schema::test ########## features = ["rc"] group cargo test --no-default-features --features rc 'roundtrip::test_rc' cargo test --no-default-features --features rc,unstable__schema 'schema::test_rc' +########## features = ["serde_json_value"] group +cargo test --features serde_json_value 'roundtrip::test_serde_json_value' +cargo test --features serde_json_value,unstable__schema 'schema::test_serde_json_value' ########## features = ["hashbrown"] group cargo test --no-default-features --features hashbrown cargo test --no-default-features --features hashbrown,derive diff --git a/borsh/tests/roundtrip/snapshots/tests__roundtrip__test_serde_json_value__json_value.snap b/borsh/tests/roundtrip/snapshots/tests__roundtrip__test_serde_json_value__json_value.snap new file mode 100644 index 000000000..e98a2f85e --- /dev/null +++ b/borsh/tests/roundtrip/snapshots/tests__roundtrip__test_serde_json_value__json_value.snap @@ -0,0 +1,833 @@ +--- +source: borsh/tests/roundtrip/test_serde_json_value.rs +expression: serialized +--- +[ + 5, + 17, + 0, + 0, + 0, + 15, + 0, + 0, + 0, + 97, + 114, + 114, + 97, + 121, + 95, + 111, + 102, + 95, + 97, + 114, + 114, + 97, + 121, + 115, + 4, + 3, + 0, + 0, + 0, + 4, + 3, + 0, + 0, + 0, + 2, + 0, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 2, + 0, + 2, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 2, + 0, + 3, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 4, + 3, + 0, + 0, + 0, + 2, + 0, + 4, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 2, + 0, + 5, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 2, + 0, + 6, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 4, + 3, + 0, + 0, + 0, + 2, + 0, + 7, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 2, + 0, + 8, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 2, + 0, + 9, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 14, + 0, + 0, + 0, + 97, + 114, + 114, + 97, + 121, + 95, + 111, + 102, + 95, + 110, + 117, + 108, + 108, + 115, + 4, + 3, + 0, + 0, + 0, + 0, + 0, + 0, + 16, + 0, + 0, + 0, + 97, + 114, + 114, + 97, + 121, + 95, + 111, + 102, + 95, + 110, + 117, + 109, + 98, + 101, + 114, + 115, + 4, + 6, + 0, + 0, + 0, + 2, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 2, + 1, + 255, + 255, + 255, + 255, + 255, + 255, + 255, + 255, + 2, + 0, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 2, + 2, + 154, + 153, + 153, + 153, + 153, + 153, + 241, + 63, + 2, + 2, + 154, + 153, + 153, + 153, + 153, + 153, + 241, + 191, + 2, + 0, + 244, + 250, + 18, + 2, + 0, + 0, + 0, + 0, + 16, + 0, + 0, + 0, + 97, + 114, + 114, + 97, + 121, + 95, + 111, + 102, + 95, + 111, + 98, + 106, + 101, + 99, + 116, + 115, + 4, + 3, + 0, + 0, + 0, + 5, + 2, + 0, + 0, + 0, + 3, + 0, + 0, + 0, + 97, + 103, + 101, + 2, + 0, + 30, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 4, + 0, + 0, + 0, + 110, + 97, + 109, + 101, + 3, + 5, + 0, + 0, + 0, + 76, + 97, + 114, + 114, + 121, + 5, + 2, + 0, + 0, + 0, + 3, + 0, + 0, + 0, + 97, + 103, + 101, + 2, + 0, + 7, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 4, + 0, + 0, + 0, + 110, + 97, + 109, + 101, + 3, + 4, + 0, + 0, + 0, + 74, + 97, + 107, + 101, + 5, + 2, + 0, + 0, + 0, + 3, + 0, + 0, + 0, + 97, + 103, + 101, + 2, + 0, + 8, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 4, + 0, + 0, + 0, + 110, + 97, + 109, + 101, + 3, + 7, + 0, + 0, + 0, + 80, + 117, + 109, + 112, + 107, + 105, + 110, + 16, + 0, + 0, + 0, + 97, + 114, + 114, + 97, + 121, + 95, + 111, + 102, + 95, + 115, + 116, + 114, + 105, + 110, + 103, + 115, + 4, + 3, + 0, + 0, + 0, + 3, + 5, + 0, + 0, + 0, + 76, + 97, + 114, + 114, + 121, + 3, + 4, + 0, + 0, + 0, + 74, + 97, + 107, + 101, + 3, + 7, + 0, + 0, + 0, + 80, + 117, + 109, + 112, + 107, + 105, + 110, + 5, + 0, + 0, + 0, + 102, + 97, + 108, + 115, + 101, + 1, + 0, + 14, + 0, + 0, + 0, + 110, + 101, + 103, + 97, + 116, + 105, + 118, + 101, + 95, + 102, + 108, + 111, + 97, + 116, + 2, + 2, + 215, + 163, + 112, + 61, + 10, + 199, + 139, + 192, + 16, + 0, + 0, + 0, + 110, + 101, + 103, + 97, + 116, + 105, + 118, + 101, + 95, + 105, + 110, + 116, + 101, + 103, + 101, + 114, + 2, + 1, + 200, + 164, + 254, + 255, + 255, + 255, + 255, + 255, + 12, + 0, + 0, + 0, + 110, + 101, + 103, + 97, + 116, + 105, + 118, + 101, + 95, + 109, + 97, + 120, + 2, + 2, + 255, + 255, + 255, + 255, + 255, + 255, + 239, + 255, + 4, + 0, + 0, + 0, + 110, + 117, + 108, + 108, + 0, + 6, + 0, + 0, + 0, + 111, + 98, + 106, + 101, + 99, + 116, + 5, + 3, + 0, + 0, + 0, + 3, + 0, + 0, + 0, + 97, + 103, + 101, + 2, + 0, + 30, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 4, + 0, + 0, + 0, + 110, + 97, + 109, + 101, + 3, + 5, + 0, + 0, + 0, + 76, + 97, + 114, + 114, + 121, + 4, + 0, + 0, + 0, + 112, + 101, + 116, + 115, + 4, + 2, + 0, + 0, + 0, + 5, + 2, + 0, + 0, + 0, + 3, + 0, + 0, + 0, + 97, + 103, + 101, + 2, + 0, + 7, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 4, + 0, + 0, + 0, + 110, + 97, + 109, + 101, + 3, + 4, + 0, + 0, + 0, + 74, + 97, + 107, + 101, + 5, + 2, + 0, + 0, + 0, + 3, + 0, + 0, + 0, + 97, + 103, + 101, + 2, + 0, + 8, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 4, + 0, + 0, + 0, + 110, + 97, + 109, + 101, + 3, + 7, + 0, + 0, + 0, + 80, + 117, + 109, + 112, + 107, + 105, + 110, + 14, + 0, + 0, + 0, + 112, + 111, + 115, + 105, + 116, + 105, + 118, + 101, + 95, + 102, + 108, + 111, + 97, + 116, + 2, + 2, + 205, + 204, + 204, + 204, + 204, + 220, + 94, + 64, + 16, + 0, + 0, + 0, + 112, + 111, + 115, + 105, + 116, + 105, + 118, + 101, + 95, + 105, + 110, + 116, + 101, + 103, + 101, + 114, + 2, + 0, + 57, + 48, + 0, + 0, + 0, + 0, + 0, + 0, + 12, + 0, + 0, + 0, + 112, + 111, + 115, + 105, + 116, + 105, + 118, + 101, + 95, + 109, + 97, + 120, + 2, + 2, + 255, + 255, + 255, + 255, + 255, + 255, + 239, + 127, + 6, + 0, + 0, + 0, + 115, + 116, + 114, + 105, + 110, + 103, + 3, + 5, + 0, + 0, + 0, + 76, + 97, + 114, + 114, + 121, + 4, + 0, + 0, + 0, + 116, + 114, + 117, + 101, + 1, + 1, + 4, + 0, + 0, + 0, + 122, + 101, + 114, + 111, + 2, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, +] diff --git a/borsh/tests/roundtrip/test_json.rs b/borsh/tests/roundtrip/test_serde_json_value.rs similarity index 95% rename from borsh/tests/roundtrip/test_json.rs rename to borsh/tests/roundtrip/test_serde_json_value.rs index 3f955d485..337d455a6 100644 --- a/borsh/tests/roundtrip/test_json.rs +++ b/borsh/tests/roundtrip/test_serde_json_value.rs @@ -53,6 +53,10 @@ fn test_json_value() { }); let serialized = borsh::to_vec(&original).unwrap(); + + #[cfg(feature = "std")] + insta::assert_debug_snapshot!(serialized); + let deserialized: serde_json::Value = borsh::from_slice(&serialized).unwrap(); assert_eq!(original, deserialized); diff --git a/borsh/tests/schema/test_serde_json_value.rs b/borsh/tests/schema/test_serde_json_value.rs new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/borsh/tests/schema/test_serde_json_value.rs @@ -0,0 +1 @@ + diff --git a/borsh/tests/tests.rs b/borsh/tests/tests.rs index cd79b272f..6ee0b4783 100644 --- a/borsh/tests/tests.rs +++ b/borsh/tests/tests.rs @@ -53,7 +53,7 @@ mod roundtrip { #[cfg(feature = "rc")] mod test_rc; #[cfg(feature = "serde_json_value")] - mod test_json; + mod test_serde_json_value; #[cfg(feature = "derive")] mod requires_derive_category { @@ -97,6 +97,9 @@ mod schema { mod test_cells; #[cfg(feature = "rc")] mod test_rc; + #[cfg(feature = "serde_json_value")] + // TODO: add content for schema tests + mod test_serde_json_value; mod test_simple_structs; mod test_generic_structs; mod test_simple_enums;