git-ents.gitmain
⌘K
foforge
account.rs59 lines · 2.2 KB · rusthistorycomment on this file
1//! Integration coverage for `git ents account` against a real local
2//! composition root (`roots.local`) — creating this repository's account
3//! identity, then reading it back (`model.account`).
4
5#![allow(clippy::expect_used, reason = "integration test")]
6
7mod common;
8
9use git_ents::commands::{account, members};
10use git_ents::root::LocalRoot;
11
12/// `git ents account show` reads back exactly what `create` wrote — the
13/// only read command against the fixed `refs/meta/account` ref
14/// (`model.account`).
15// @relation(roots.local, model.account, scope=function, role=Verifies)
16#[test]
17fn show_reads_back_the_created_identity() {
18 let fixture = common::Fixture::new(1);
19 let root = LocalRoot::open(fixture.path()).expect("opens");
20 members::add(&root, "jdc", None, Some(fixture.key_path.clone())).expect("bootstrap");
21
22 account::create(
23 &root,
24 Some("jdc".to_owned()),
25 "joseph.carpinelli@icloud.com".to_owned(),
26 Some(fixture.key_path.clone()),
27 )
28 .expect("creates");
29
30 let account = account::show(&root).expect("shows");
31 assert_eq!(account.member, ents_model::MemberId::new("jdc"));
32 assert_eq!(account.login, "joseph.carpinelli@icloud.com");
33}
34
35/// Omitting `--member` resolves the owning member from the *given* `--key`,
36/// not from whatever key the host's own default resolution would pick —
37/// otherwise `create` could silently attribute the account to the wrong
38/// member when signing with a non-default key.
39// @relation(roots.local, model.account, scope=function, role=Verifies)
40#[test]
41fn create_without_member_resolves_from_the_given_key() {
42 let fixture = common::Fixture::new(1);
43 let root = LocalRoot::open(fixture.path()).expect("opens");
44 members::add(&root, "jdc", None, Some(fixture.key_path.clone())).expect("bootstrap jdc");
45
46 let other_key_path = common::write_key_in(fixture.path(), 2);
47 members::add(&root, "other", None, Some(other_key_path.clone())).expect("bootstrap other");
48
49 account::create(
50 &root,
51 None,
52 "other@example.com".to_owned(),
53 Some(other_key_path),
54 )
55 .expect("creates");
56
57 let account = account::show(&root).expect("shows");
58 assert_eq!(account.member, ents_model::MemberId::new("other"));
59}