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

Source from the content-addressed store, hash-verified

1773 #[test]
1774 #[file_serial]
1775 fn test_diff_word_diff_enabled() {
1776 let _guard = DirGuard::new();
1777
1778 let temp_dir = tempfile::tempdir().unwrap();
1779 let repo_path = temp_dir.path();
1780
1781 // Initialize repository and create initial file
1782 {
1783 let repo = Repository::init(repo_path).unwrap();
1784 std::fs::write(repo_path.join("code.rs"), "let x = 42;\n").unwrap();
1785 let working_copy = repo.require_working_copy_id().unwrap();
1786 repo.add(working_copy, "code.rs", Default::default())
1787 .unwrap();
1788
1789 // Record the initial state
1790 let header = atomic_core::change::ChangeHeader::builder()
1791 .message("Initial commit")
1792 .build();
1793 repo.record(working_copy, header, Default::default())
1794 .unwrap();
1795 }
1796
1797 // Modify the file (change value)
1798 std::fs::write(repo_path.join("code.rs"), "let x = 100;\n").unwrap();
1799
1800 std::env::set_current_dir(repo_path).unwrap();
1801
1802 // Create diff with word-diff enabled
1803 let diff = Diff::new().with_word_diff(true).with_no_color(false); // Ensure color is on for word-diff
1804
1805 assert!(diff.word_diff);
1806
1807 let config = diff.get_output_config();
1808 assert!(config.word_diff);
1809
1810 // Run should succeed
1811 let result = diff.run();
1812 assert!(result.is_ok());
1813 }
1814
1815 #[test]
1816 #[file_serial]

Callers

nothing calls this directly

Calls 13

with_no_colorMethod · 0.80
get_output_configMethod · 0.80
initFunction · 0.50
writeFunction · 0.50
unwrapMethod · 0.45
pathMethod · 0.45
addMethod · 0.45
buildMethod · 0.45
messageMethod · 0.45
recordMethod · 0.45
with_word_diffMethod · 0.45

Tested by

no test coverage detected