From 65e1e141eab96dc31a04ccb94d316ce381f9c25f Mon Sep 17 00:00:00 2001 From: Jon Seager Date: Wed, 26 Nov 2025 16:28:00 +0000 Subject: [PATCH] fix(test): fix race condition in CLI test --- tests/cli/tokens_cli.rs | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/tests/cli/tokens_cli.rs b/tests/cli/tokens_cli.rs index 40a37e5..97bc2d7 100644 --- a/tests/cli/tokens_cli.rs +++ b/tests/cli/tokens_cli.rs @@ -57,21 +57,26 @@ 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 revoke_output = run_brewlog( - &["revoke-token", "--id", &token_id.to_string()], - &[("BREWLOG_TOKEN", &token)], - ); + let token_id = token_to_revoke["id"] + .as_i64() + .expect("Token should have ID"); - assert!( - revoke_output.status.success(), - "Should be able to revoke token" - ); - } + let revoke_output = run_brewlog( + &["revoke-token", "--id", &token_id.to_string()], + &[("BREWLOG_TOKEN", &token)], + ); + + assert!( + revoke_output.status.success(), + "Should be able to revoke token" + ); } #[test]