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 =
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");
if let Some(first_token) = tokens_array.first() {
let token_id = first_token["id"].as_i64().expect("Token should have ID");
let token_to_revoke = tokens_array
.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(
&["revoke-token", "--id", &token_id.to_string()],
@ -72,7 +78,6 @@ fn test_revoke_token_with_authentication() {
"Should be able to revoke token"
);
}
}
#[test]
fn test_revoked_token_cannot_be_used() {