Skip to content

Commit 3eab78d

Browse files
committed
test(common): support renames are checked as one table of events and actors
1 parent 5c24b68 commit 3eab78d

1 file changed

Lines changed: 22 additions & 31 deletions

File tree

‎crates/common/src/notifications/tests.rs‎

Lines changed: 22 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -25,41 +25,32 @@ fn admin() -> Actor {
2525
/// tells its owner; the owner doing so does not.
2626
#[test]
2727
fn only_support_renames_notify() {
28-
let renamed = DomainEvent::DisplayNameChanged {
29-
old: Personal::Value("Ada".to_owned()),
30-
new: Personal::Value("Ada L.".to_owned()),
31-
};
32-
assert_eq!(renamed.notification(&owner()), None);
33-
assert_eq!(
34-
renamed.notification(&admin()),
35-
Some(Notification::DisplayNameChanged)
36-
);
3728
let cli = Actor::Cli {
3829
os_user: "root".to_owned(),
3930
host: "host".to_owned(),
4031
};
41-
assert_eq!(
42-
renamed.notification(&cli),
43-
Some(Notification::DisplayNameChanged)
44-
);
45-
let passkey = DomainEvent::PasskeyRenamed {
46-
passkey_id: PasskeyId::new(),
47-
};
48-
assert_eq!(passkey.notification(&owner()), None);
49-
assert_eq!(
50-
passkey.notification(&admin()),
51-
Some(Notification::PasskeyRenamed)
52-
);
53-
assert_eq!(
54-
passkey.notification(&cli),
55-
Some(Notification::PasskeyRenamed)
56-
);
57-
let removed = DomainEvent::PictureRemoved {};
58-
assert_eq!(removed.notification(&owner()), None);
59-
assert_eq!(
60-
removed.notification(&admin()),
61-
Some(Notification::PictureRemoved)
62-
);
32+
for (event, notification) in [
33+
(
34+
DomainEvent::DisplayNameChanged {
35+
old: Personal::Value("Ada".to_owned()),
36+
new: Personal::Value("Ada L.".to_owned()),
37+
},
38+
Notification::DisplayNameChanged,
39+
),
40+
(
41+
DomainEvent::PasskeyRenamed {
42+
passkey_id: PasskeyId::new(),
43+
},
44+
Notification::PasskeyRenamed,
45+
),
46+
(DomainEvent::PictureRemoved {}, Notification::PictureRemoved),
47+
] {
48+
assert_eq!(event.notification(&owner()), None, "{event:?}");
49+
for support in [admin(), cli.clone()] {
50+
let expected = Some(notification.clone());
51+
assert_eq!(event.notification(&support), expected, "{event:?}");
52+
}
53+
}
6354
}
6455

6556
/// Only a primary address that replaced another tells the owner: the first

0 commit comments

Comments
 (0)