fix(test): fix race condition in CLI test

This commit is contained in:
Jon Seager 2025-11-26 16:28:00 +00:00
parent 4358fa63dc
commit 65e1e141ea
No known key found for this signature in database

View file

@ -57,10 +57,16 @@ fn test_revoke_token_with_authentication() {
let tokens: serde_json::Value = let tokens: serde_json::Value =
serde_json::from_str(&list_stdout).expect("Should parse token list as JSON"); serde_json::from_str(&list_stdout).expect("Should parse token list as JSON");
// Find a token to revoke // Find the token to revoke by name
let tokens_array = tokens.as_array().expect("Should be an array"); let tokens_array = tokens.as_array().expect("Should be an array");
if let Some(first_token) = tokens_array.first() { let token_to_revoke = tokens_array
let token_id = first_token["id"].as_i64().expect("Token should have ID"); .iter()
.find(|t| t["name"].as_str() == Some("test-revoke-token"))
.expect("Should find token to revoke");
let token_id = token_to_revoke["id"]
.as_i64()
.expect("Token should have ID");
let revoke_output = run_brewlog( let revoke_output = run_brewlog(
&["revoke-token", "--id", &token_id.to_string()], &["revoke-token", "--id", &token_id.to_string()],
@ -72,7 +78,6 @@ fn test_revoke_token_with_authentication() {
"Should be able to revoke token" "Should be able to revoke token"
); );
} }
}
#[test] #[test]
fn test_revoked_token_cannot_be_used() { fn test_revoked_token_cannot_be_used() {