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

Function test_diff_word_diff_enabled

atomic-cli/src/commands/diff/tests.rs:1496–1531  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1494 #[test]
1495 #[serial]
1496 fn test_diff_word_diff_enabled() {
1497 let _guard = DirGuard::new();
1498
1499 let temp_dir = tempfile::tempdir().unwrap();
1500 let repo_path = temp_dir.path();
1501
1502 // Initialize repository and create initial file
1503 {
1504 let repo = Repository::init(repo_path).unwrap();
1505 std::fs::write(repo_path.join("code.rs"), "let x = 42;\n").unwrap();
1506 repo.add("code.rs", Default::default()).unwrap();
1507
1508 // Record the initial state
1509 let header = atomic_core::change::ChangeHeader::builder()
1510 .message("Initial commit")
1511 .build();
1512 repo.record(header, Default::default()).unwrap();
1513 }
1514
1515 // Modify the file (change value)
1516 std::fs::write(repo_path.join("code.rs"), "let x = 100;\n").unwrap();
1517
1518 std::env::set_current_dir(repo_path).unwrap();
1519
1520 // Create diff with word-diff enabled
1521 let diff = Diff::new().with_word_diff(true).with_no_color(false); // Ensure color is on for word-diff
1522
1523 assert!(diff.word_diff);
1524
1525 let config = diff.get_output_config();
1526 assert!(config.word_diff);
1527
1528 // Run should succeed
1529 let result = diff.run();
1530 assert!(result.is_ok());
1531 }
1532
1533 #[test]
1534 #[serial]

Callers

nothing calls this directly

Calls 11

writeFunction · 0.85
with_no_colorMethod · 0.80
get_output_configMethod · 0.80
unwrapMethod · 0.45
pathMethod · 0.45
addMethod · 0.45
buildMethod · 0.45
messageMethod · 0.45
recordMethod · 0.45
with_word_diffMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected