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:
kosmos authored and Valentin Haudiquet committed 2026-11-08 17:54:15 +01:00
1 parent 875b2f0ed8
commit 853c5a547c
2 files changed
+7 -5

No files matched your search

+1 -1
View File
@@ -161,7 +161,7 @@ pub fn resolve_watch_credential(
.filter(|account| host_matches(host, account.url.as_deref()))
.find_map(|account| {
let secret = accounts.secret(&account.id).ok()??;
(secret.kind == SecretKind::Token).then(|| WatchCredential {
(secret.kind == SecretKind::Token).then_some(WatchCredential {
token: secret.value,
login: account.username,
})
+6 -4
View File
@@ -929,11 +929,8 @@ mod tests {
#[test]
fn an_account_watch_resolves_the_client_a_repo_watch_would_have() {
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());
accounts
let account = accounts
.put(
rhema_identity::AccountDraft::new(
"kosmos",
@@ -944,6 +941,11 @@ mod tests {
.with_username("kosmos"),
)
.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(
crate::backends::BackendRegistry::new(
vec![crate::backends::Backend::headless(