MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / test_store_default_by_usage

Function test_store_default_by_usage

atomic-identity/src/store.rs:1050–1080  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1048
1049 #[test]
1050 fn test_store_default_by_usage() {
1051 let (_temp, mut store) = create_test_store();
1052
1053 let personal = Identity::builder("alice-personal")
1054 .usage(IdentityUsage::Personal)
1055 .build()
1056 .unwrap();
1057 let work = Identity::builder("alice-work")
1058 .usage(IdentityUsage::Work)
1059 .build()
1060 .unwrap();
1061
1062 store.save(&personal).unwrap();
1063 store.save(&work).unwrap();
1064
1065 store
1066 .set_default_for_usage(&IdentityUsage::Work, &work.id)
1067 .unwrap();
1068
1069 let work_default = store
1070 .get_default_for_usage(&IdentityUsage::Work)
1071 .unwrap()
1072 .unwrap();
1073 assert_eq!(work_default.id, work.id);
1074
1075 // Personal should fall back to None (no global default set)
1076 assert!(store
1077 .get_default_for_usage(&IdentityUsage::Personal)
1078 .unwrap()
1079 .is_none());
1080 }
1081
1082 #[test]
1083 fn test_store_exists() {

Callers

nothing calls this directly

Calls 7

set_default_for_usageMethod · 0.80
get_default_for_usageMethod · 0.80
create_test_storeFunction · 0.70
unwrapMethod · 0.45
buildMethod · 0.45
usageMethod · 0.45
saveMethod · 0.45

Tested by

no test coverage detected