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:1734–1769  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1732 #[test]
1733 #[serial]
1734 fn test_diff_word_diff_enabled() {
1735 let _guard = DirGuard::new();
1736
1737 let temp_dir = tempfile::tempdir().unwrap();
1738 let repo_path = temp_dir.path();
1739
1740 // Initialize repository and create initial file
1741 {
1742 let repo = Repository::init(repo_path).unwrap();
1743 std::fs::write(repo_path.join("code.rs"), "let x = 42;\n").unwrap();
1744 repo.add("code.rs", Default::default()).unwrap();
1745
1746 // Record the initial state
1747 let header = atomic_core::change::ChangeHeader::builder()
1748 .message("Initial commit")
1749 .build();
1750 repo.record(header, Default::default()).unwrap();
1751 }
1752
1753 // Modify the file (change value)
1754 std::fs::write(repo_path.join("code.rs"), "let x = 100;\n").unwrap();
1755
1756 std::env::set_current_dir(repo_path).unwrap();
1757
1758 // Create diff with word-diff enabled
1759 let diff = Diff::new().with_word_diff(true).with_no_color(false); // Ensure color is on for word-diff
1760
1761 assert!(diff.word_diff);
1762
1763 let config = diff.get_output_config();
1764 assert!(config.word_diff);
1765
1766 // Run should succeed
1767 let result = diff.run();
1768 assert!(result.is_ok());
1769 }
1770
1771 #[test]
1772 #[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