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:899–929  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

897
898 #[test]
899 fn test_store_default_by_usage() {
900 let (_temp, mut store) = create_test_store();
901
902 let personal = Identity::builder("alice-personal")
903 .usage(IdentityUsage::Personal)
904 .build()
905 .unwrap();
906 let work = Identity::builder("alice-work")
907 .usage(IdentityUsage::Work)
908 .build()
909 .unwrap();
910
911 store.save(&personal).unwrap();
912 store.save(&work).unwrap();
913
914 store
915 .set_default_for_usage(&IdentityUsage::Work, &work.id)
916 .unwrap();
917
918 let work_default = store
919 .get_default_for_usage(&IdentityUsage::Work)
920 .unwrap()
921 .unwrap();
922 assert_eq!(work_default.id, work.id);
923
924 // Personal should fall back to None (no global default set)
925 assert!(store
926 .get_default_for_usage(&IdentityUsage::Personal)
927 .unwrap()
928 .is_none());
929 }
930
931 #[test]
932 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