MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / assert_guard_refusal

Function assert_guard_refusal

atomic-cli/tests/it/git_guard_cb0c_test.rs:325–407  ·  view source on GitHub ↗
(fixture: &Fixture, operation: &str, args: &[&str])

Source from the content-addressed store, hash-verified

323}
324
325fn assert_guard_refusal(fixture: &Fixture, operation: &str, args: &[&str]) {
326 let before = RepositorySnapshot::capture(fixture);
327 let output = fixture.atomic(args);
328 assert!(
329 !output.status.success(),
330 "atomic {} unexpectedly succeeded",
331 args.join(" ")
332 );
333 assert!(
334 output.stdout.is_empty(),
335 "{} emitted mass stdout before refusal:\n{}",
336 args.join(" "),
337 String::from_utf8_lossy(&output.stdout)
338 );
339 let report = String::from_utf8_lossy(&output.stderr);
340 if report.contains("workspace reconciliation required") {
341 assert!(report.contains("HeadSymrefChanged"), "{report}");
342 assert!(report.contains("refs/heads/main"), "{report}");
343 assert!(report.contains("refs/heads/raw-drift"), "{report}");
344 assert!(!report.contains("mass-output-000.txt"), "{report}");
345 let after = RepositorySnapshot::capture(fixture);
346 assert_snapshot_unchanged(
347 &before,
348 &after,
349 &format!(
350 "atomic {} mutated Git, Atomic, or working-copy state before refusal",
351 args.join(" ")
352 ),
353 );
354 return;
355 }
356 for expected in [
357 format!("Unsafe operation: {operation}"),
358 "Refusal: Git moved away from the shim checkpoint".to_string(),
359 "Old checkpoint Atomic view: main".to_string(),
360 "Old checkpoint Atomic state:".to_string(),
361 "Old checkpoint Atomic manifest root: atomic-visible-regular-files-blake3-v1:".to_string(),
362 "Old checkpoint Git HEAD: attached refs/heads/main at ".to_string(),
363 "Old checkpoint Git HEAD tree:".to_string(),
364 "Old checkpoint Git index tree:".to_string(),
365 "Old checkpoint Git index digest:".to_string(),
366 "Old checkpoint Git refs digest:".to_string(),
367 "Old checkpoint Git refs: digest-only checkpoint evidence".to_string(),
368 "Old checkpoint Git manifest root: git-tree-oid:".to_string(),
369 "Current Atomic view: main".to_string(),
370 "Current Atomic state:".to_string(),
371 "Current Atomic manifest root: atomic-visible-regular-files-blake3-v1:".to_string(),
372 "Current Git HEAD: attached refs/heads/raw-drift at ".to_string(),
373 "Current Git HEAD tree:".to_string(),
374 "Current Git index tree:".to_string(),
375 "Current Git index digest:".to_string(),
376 "Current Git refs digest:".to_string(),
377 "Current Git refs:".to_string(),
378 "refs/heads/main ->".to_string(),
379 "refs/heads/raw-drift ->".to_string(),
380 "Current Git manifest root: git-tree-oid:".to_string(),
381 ] {
382 assert!(

Calls 4

captureFunction · 0.50
atomicMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected