Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test(ci): require the reloaded token and the exact import count

M3gA-Mind76118f09e614
diff --git a/tests/cli_sigpipe.rs b/tests/cli_sigpipe.rs
index 084bf5d1f0..b59ba3adda 100644
--- a/tests/cli_sigpipe.rs
+++ b/tests/cli_sigpipe.rs
@@ -151,13 +151,29 @@ fn headless_default_keyring_stores_provider_secrets_encrypted() {
.output()
.expect("run provider credential list command");
let stdout = String::from_utf8_lossy(&listed.stdout);
+ let listing: serde_json::Value = serde_json::from_str(&stdout).unwrap_or_default();
+ // The profile must come back with its token, not just its metadata: a lost
+ // token still lists the profile with `hasToken: false`.
assert!(
- listed.status.success() && stdout.contains("openai"),
- "stored credential not listed: stdout={stdout} stderr={}",
+ listed.status.success() && lists_openai_token(&listing),
+ "stored credential not read back with its token: stdout={stdout} stderr={}",
String::from_utf8_lossy(&listed.stderr)
);
}
+/// Whether `value` holds the `openai` profile summary with its token present.
+fn lists_openai_token(value: &serde_json::Value) -> bool {
+ match value {
+ serde_json::Value::Object(map) => {
+ (map.get("provider").and_then(serde_json::Value::as_str) == Some("openai")
+ && map.get("hasToken").and_then(serde_json::Value::as_bool) == Some(true))
+ || map.values().any(lists_openai_token)
+ }
+ serde_json::Value::Array(items) => items.iter().any(lists_openai_token),
+ _ => false,
+ }
+}
+
/// Every regular file under `root`, recursively.
fn files_under(root: &std::path::Path) -> Vec<std::path::PathBuf> {
let mut files = Vec::new();
diff --git a/tests/raw_coverage/session_store_e2e.rs b/tests/raw_coverage/session_store_e2e.rs
index 2e5786c8fc..76876c6706 100644
--- a/tests/raw_coverage/session_store_e2e.rs
+++ b/tests/raw_coverage/session_store_e2e.rs
@@ -336,15 +336,11 @@ async fn session_import_plans_imports_then_skips_on_rerun() {
imported.get("dry_run").and_then(Value::as_bool),
Some(false)
);
- let outcome = sessions_outcome(&imported);
- let written = outcome
- .strip_prefix("Imported {")
- .and_then(|rest| rest.split("written: ").nth(1))
- .and_then(|rest| rest.trim_end_matches([' ', '}']).parse::<u64>().ok())
- .unwrap_or_else(|| panic!("the real run must import: {imported}"));
- assert!(
- written > 0,
- "the transcript's messages must be written: {imported}"
+ // `found`/`written` count transcripts: the one seeded file is written.
+ assert_eq!(
+ sessions_outcome(&imported),
+ "Imported { found: 1, written: 1 }",
+ "the seeded transcript must be imported: {imported}"
);
// ── re-run: idempotent, short-circuited by the per-workspace marker ──