fix(claw): the account-watch test names the id the store assigned, and clippy's then_some
The test fabricated `acct-1` as the watch's account id, but `put`
assigns its own, so the dispatch refused with "names account acct-1,
which is gone" — the test proved nothing about the path it covered.
Capture the assigned id instead.
`(secret.kind == SecretKind::Token).then(|| WatchCredential { .. })`
constructs a value with no work, so clippy's unnecessary_lazy_evaluations
failed `checks`; `then_some` says the same thing.
This commit is contained in:
1 parent
875b2f0ed8
commit
853c5a547c
2 files changed
+7
-5
No files matched your search
@@ -161,7 +161,7 @@ pub fn resolve_watch_credential(
|
|||||||
.filter(|account| host_matches(host, account.url.as_deref()))
|
.filter(|account| host_matches(host, account.url.as_deref()))
|
||||||
.find_map(|account| {
|
.find_map(|account| {
|
||||||
let secret = accounts.secret(&account.id).ok()??;
|
let secret = accounts.secret(&account.id).ok()??;
|
||||||
(secret.kind == SecretKind::Token).then(|| WatchCredential {
|
(secret.kind == SecretKind::Token).then_some(WatchCredential {
|
||||||
token: secret.value,
|
token: secret.value,
|
||||||
login: account.username,
|
login: account.username,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -929,11 +929,8 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn an_account_watch_resolves_the_client_a_repo_watch_would_have() {
|
fn an_account_watch_resolves_the_client_a_repo_watch_would_have() {
|
||||||
let watches = Arc::new(ClawStore::in_memory().expect("store opens"));
|
let watches = Arc::new(ClawStore::in_memory().expect("store opens"));
|
||||||
watches
|
|
||||||
.add_account_watch("gitea", Some("https://git.example"), "acct-1")
|
|
||||||
.expect("account watch lands");
|
|
||||||
let accounts = Arc::new(rhema_identity::VolatileIdentityStore::new());
|
let accounts = Arc::new(rhema_identity::VolatileIdentityStore::new());
|
||||||
accounts
|
let account = accounts
|
||||||
.put(
|
.put(
|
||||||
rhema_identity::AccountDraft::new(
|
rhema_identity::AccountDraft::new(
|
||||||
"kosmos",
|
"kosmos",
|
||||||
@@ -944,6 +941,11 @@ mod tests {
|
|||||||
.with_username("kosmos"),
|
.with_username("kosmos"),
|
||||||
)
|
)
|
||||||
.expect("account lands");
|
.expect("account lands");
|
||||||
|
// The watch row names the id the store actually assigned: a
|
||||||
|
// fabricated id is a row that resolves nothing.
|
||||||
|
watches
|
||||||
|
.add_account_watch("gitea", Some("https://git.example"), &account.id)
|
||||||
|
.expect("account watch lands");
|
||||||
let registry = Arc::new(
|
let registry = Arc::new(
|
||||||
crate::backends::BackendRegistry::new(
|
crate::backends::BackendRegistry::new(
|
||||||
vec![crate::backends::Backend::headless(
|
vec![crate::backends::Backend::headless(
|
||||||
|
|||||||
Reference in new issue
Block a user