Skip to content

Commit 6c9b1ef

Browse files
committed
fix(common): Rename all snapshots in deserialized_responses to have shorter names
1 parent 8cceded commit 6c9b1ef

22 files changed

+81
-46
lines changed

crates/matrix-sdk-common/src/deserialized_responses.rs

Lines changed: 42 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,49 +1283,57 @@ mod tests {
12831283

12841284
#[test]
12851285
fn snapshot_test_verification_level() {
1286-
assert_json_snapshot!(VerificationLevel::VerificationViolation);
1287-
assert_json_snapshot!(VerificationLevel::UnsignedDevice);
1288-
assert_json_snapshot!(VerificationLevel::None(DeviceLinkProblem::InsecureSource));
1289-
assert_json_snapshot!(VerificationLevel::None(DeviceLinkProblem::MissingDevice));
1290-
assert_json_snapshot!(VerificationLevel::UnverifiedIdentity);
1286+
with_settings!({ prepend_module_to_snapshot => false }, {
1287+
assert_json_snapshot!(VerificationLevel::VerificationViolation);
1288+
assert_json_snapshot!(VerificationLevel::UnsignedDevice);
1289+
assert_json_snapshot!(VerificationLevel::None(DeviceLinkProblem::InsecureSource));
1290+
assert_json_snapshot!(VerificationLevel::None(DeviceLinkProblem::MissingDevice));
1291+
assert_json_snapshot!(VerificationLevel::UnverifiedIdentity);
1292+
});
12911293
}
12921294

12931295
#[test]
12941296
fn snapshot_test_verification_states() {
1295-
assert_json_snapshot!(VerificationState::Unverified(VerificationLevel::UnsignedDevice));
1296-
assert_json_snapshot!(VerificationState::Unverified(
1297-
VerificationLevel::VerificationViolation
1298-
));
1299-
assert_json_snapshot!(VerificationState::Unverified(VerificationLevel::None(
1300-
DeviceLinkProblem::InsecureSource,
1301-
)));
1302-
assert_json_snapshot!(VerificationState::Unverified(VerificationLevel::None(
1303-
DeviceLinkProblem::MissingDevice,
1304-
)));
1305-
assert_json_snapshot!(VerificationState::Verified);
1297+
with_settings!({ prepend_module_to_snapshot => false }, {
1298+
assert_json_snapshot!(VerificationState::Unverified(VerificationLevel::UnsignedDevice));
1299+
assert_json_snapshot!(VerificationState::Unverified(
1300+
VerificationLevel::VerificationViolation
1301+
));
1302+
assert_json_snapshot!(VerificationState::Unverified(VerificationLevel::None(
1303+
DeviceLinkProblem::InsecureSource,
1304+
)));
1305+
assert_json_snapshot!(VerificationState::Unverified(VerificationLevel::None(
1306+
DeviceLinkProblem::MissingDevice,
1307+
)));
1308+
assert_json_snapshot!(VerificationState::Verified);
1309+
});
13061310
}
13071311

13081312
#[test]
13091313
fn snapshot_test_shield_states() {
1310-
assert_json_snapshot!(ShieldState::None);
1311-
assert_json_snapshot!(ShieldState::Red {
1312-
code: ShieldStateCode::UnverifiedIdentity,
1313-
message: "a message"
1314-
});
1315-
assert_json_snapshot!(ShieldState::Grey {
1316-
code: ShieldStateCode::AuthenticityNotGuaranteed,
1317-
message: "authenticity of this message cannot be guaranteed",
1314+
with_settings!({ prepend_module_to_snapshot => false }, {
1315+
assert_json_snapshot!(ShieldState::None);
1316+
assert_json_snapshot!(ShieldState::Red {
1317+
code: ShieldStateCode::UnverifiedIdentity,
1318+
message: "a message"
1319+
});
1320+
assert_json_snapshot!(ShieldState::Grey {
1321+
code: ShieldStateCode::AuthenticityNotGuaranteed,
1322+
message: "authenticity of this message cannot be guaranteed",
1323+
});
13181324
});
13191325
}
13201326

13211327
#[test]
13221328
fn snapshot_test_shield_codes() {
1323-
assert_json_snapshot!(ShieldStateCode::AuthenticityNotGuaranteed);
1324-
assert_json_snapshot!(ShieldStateCode::UnknownDevice);
1325-
assert_json_snapshot!(ShieldStateCode::UnsignedDevice);
1326-
assert_json_snapshot!(ShieldStateCode::UnverifiedIdentity);
1327-
assert_json_snapshot!(ShieldStateCode::SentInClear);
1328-
assert_json_snapshot!(ShieldStateCode::VerificationViolation);
1329+
with_settings!({ prepend_module_to_snapshot => false }, {
1330+
assert_json_snapshot!(ShieldStateCode::AuthenticityNotGuaranteed);
1331+
assert_json_snapshot!(ShieldStateCode::UnknownDevice);
1332+
assert_json_snapshot!(ShieldStateCode::UnsignedDevice);
1333+
assert_json_snapshot!(ShieldStateCode::UnverifiedIdentity);
1334+
assert_json_snapshot!(ShieldStateCode::SentInClear);
1335+
assert_json_snapshot!(ShieldStateCode::VerificationViolation);
1336+
});
13291337
}
13301338

13311339
#[test]
@@ -1341,7 +1349,9 @@ mod tests {
13411349
]),
13421350
};
13431351

1344-
assert_json_snapshot!(info)
1352+
with_settings!({ prepend_module_to_snapshot => false }, {
1353+
assert_json_snapshot!(info)
1354+
});
13451355
}
13461356

13471357
#[test]
@@ -1397,7 +1407,7 @@ mod tests {
13971407
push_actions: Default::default(),
13981408
};
13991409

1400-
with_settings!({sort_maps =>true}, {
1410+
with_settings!({ sort_maps => true, prepend_module_to_snapshot => false }, {
14011411
// We use directly the serde_json formatter here, because of a bug in insta
14021412
// not serializing custom BTreeMap key enum https://github.com/mitsuhiko/insta/issues/689
14031413
assert_json_snapshot! {
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
source: crates/matrix-sdk-common/src/deserialized_responses.rs
3+
expression: "ShieldStateCode::UnknownDevice"
4+
---
5+
"UnknownDevice"
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
22
source: crates/matrix-sdk-common/src/deserialized_responses.rs
3-
expression: "serde_json::to_value(&level).unwrap()"
3+
expression: "ShieldStateCode::UnsignedDevice"
44
---
55
"UnsignedDevice"
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
22
source: crates/matrix-sdk-common/src/deserialized_responses.rs
3-
expression: "serde_json::to_value(&level).unwrap()"
3+
expression: "ShieldStateCode::UnverifiedIdentity"
44
---
55
"UnverifiedIdentity"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
source: crates/matrix-sdk-common/src/deserialized_responses.rs
3+
expression: "ShieldStateCode::SentInClear"
4+
---
5+
"SentInClear"
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
22
source: crates/matrix-sdk-common/src/deserialized_responses.rs
3-
expression: "serde_json::to_value(&level).unwrap()"
3+
expression: "ShieldStateCode::VerificationViolation"
44
---
55
"VerificationViolation"
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
22
source: crates/matrix-sdk-common/src/deserialized_responses.rs
3-
expression: "serde_json::to_value(&code).unwrap()"
3+
expression: "ShieldStateCode::AuthenticityNotGuaranteed"
44
---
55
"AuthenticityNotGuaranteed"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
source: crates/matrix-sdk-common/src/deserialized_responses.rs
3-
expression: "serde_json::to_value(&state).unwrap()"
3+
expression: "ShieldState::Red\n{ code: ShieldStateCode::UnverifiedIdentity, message: \"a message\" }"
44
---
55
{
66
"Red": {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
source: crates/matrix-sdk-common/src/deserialized_responses.rs
3-
expression: "serde_json::to_value(&state).unwrap()"
3+
expression: "ShieldState::Grey\n{\n code: ShieldStateCode::AuthenticityNotGuaranteed, message:\n \"authenticity of this message cannot be guaranteed\",\n}"
44
---
55
{
66
"Grey": {
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
22
source: crates/matrix-sdk-common/src/deserialized_responses.rs
3-
expression: "serde_json::to_value(&state).unwrap()"
3+
expression: "ShieldState::None"
44
---
55
"None"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
source: crates/matrix-sdk-common/src/deserialized_responses.rs
3+
expression: "VerificationLevel::UnsignedDevice"
4+
---
5+
"UnsignedDevice"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
source: crates/matrix-sdk-common/src/deserialized_responses.rs
3-
expression: "serde_json::to_value(&level).unwrap()"
3+
expression: "VerificationLevel::None(DeviceLinkProblem::InsecureSource)"
44
---
55
{
66
"None": "InsecureSource"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
source: crates/matrix-sdk-common/src/deserialized_responses.rs
3-
expression: "serde_json::to_value(&level).unwrap()"
3+
expression: "VerificationLevel::None(DeviceLinkProblem::MissingDevice)"
44
---
55
{
66
"None": "MissingDevice"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
source: crates/matrix-sdk-common/src/deserialized_responses.rs
3+
expression: "VerificationLevel::UnverifiedIdentity"
4+
---
5+
"UnverifiedIdentity"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
source: crates/matrix-sdk-common/src/deserialized_responses.rs
3+
expression: "VerificationLevel::VerificationViolation"
4+
---
5+
"VerificationViolation"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
source: crates/matrix-sdk-common/src/deserialized_responses.rs
3-
expression: "serde_json::to_value(&state).unwrap()"
3+
expression: "VerificationState::Unverified(VerificationLevel::VerificationViolation)"
44
---
55
{
66
"Unverified": "VerificationViolation"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
source: crates/matrix-sdk-common/src/deserialized_responses.rs
3-
expression: "serde_json::to_value(&state).unwrap()"
3+
expression: "VerificationState::Unverified(VerificationLevel::None(DeviceLinkProblem::InsecureSource,))"
44
---
55
{
66
"Unverified": {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
source: crates/matrix-sdk-common/src/deserialized_responses.rs
3-
expression: "serde_json::to_value(&state).unwrap()"
3+
expression: "VerificationState::Unverified(VerificationLevel::None(DeviceLinkProblem::MissingDevice,))"
44
---
55
{
66
"Unverified": {
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
22
source: crates/matrix-sdk-common/src/deserialized_responses.rs
3-
expression: "serde_json::to_value(&state).unwrap()"
3+
expression: "VerificationState::Verified"
44
---
55
"Verified"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
source: crates/matrix-sdk-common/src/deserialized_responses.rs
3-
expression: "serde_json::to_value(&state).unwrap()"
3+
expression: "VerificationState::Unverified(VerificationLevel::UnsignedDevice)"
44
---
55
{
66
"Unverified": "UnsignedDevice"

0 commit comments

Comments
 (0)