diff --git a/tests/modules/programs/diff-highlight/default.nix b/tests/modules/programs/diff-highlight/default.nix new file mode 100644 index 00000000..5bdbe52d --- /dev/null +++ b/tests/modules/programs/diff-highlight/default.nix @@ -0,0 +1,5 @@ +{ + diff-highlight-basic = ./diff-highlight-basic.nix; + diff-highlight-with-git-integration = ./diff-highlight-with-git-integration.nix; + diff-highlight-migration = ./diff-highlight-migration.nix; +} diff --git a/tests/modules/programs/diff-highlight/diff-highlight-basic.nix b/tests/modules/programs/diff-highlight/diff-highlight-basic.nix new file mode 100644 index 00000000..8fb7b655 --- /dev/null +++ b/tests/modules/programs/diff-highlight/diff-highlight-basic.nix @@ -0,0 +1,16 @@ +{ + programs.diff-highlight = { + enable = true; + pagerOpts = [ + "--tabs=4" + "-RFX" + ]; + }; + programs.git.enable = true; + + nmt.script = '' + # Git config should NOT contain diff-highlight configuration since enableGitIntegration is false by default + assertFileNotRegex home-files/.config/git/config 'pager = .*/diff-highlight' + assertFileNotRegex home-files/.config/git/config 'diffFilter = .*/diff-highlight' + ''; +} diff --git a/tests/modules/programs/diff-highlight/diff-highlight-migration.nix b/tests/modules/programs/diff-highlight/diff-highlight-migration.nix new file mode 100644 index 00000000..7f151655 --- /dev/null +++ b/tests/modules/programs/diff-highlight/diff-highlight-migration.nix @@ -0,0 +1,33 @@ +{ + lib, + options, + ... +}: + +{ + programs.git = { + enable = true; + diff-highlight = { + enable = true; + pagerOpts = [ + "--tabs=4" + "-RFX" + ]; + }; + }; + + test.asserts.warnings.expected = [ + "The option `programs.git.diff-highlight.pagerOpts' defined in ${lib.showFiles options.programs.git.diff-highlight.pagerOpts.files} has been renamed to `programs.diff-highlight.pagerOpts'." + "The option `programs.git.diff-highlight.enable' defined in ${lib.showFiles options.programs.git.diff-highlight.enable.files} has been renamed to `programs.diff-highlight.enable'." + "`programs.diff-highlight.enableGitIntegration` automatic enablement is deprecated. Please explicitly set `programs.diff-highlight.enableGitIntegration = true`." + ]; + + nmt.script = '' + # Git config should contain diff-highlight configuration (backward compatibility) + assertFileExists home-files/.config/git/config + assertFileContains home-files/.config/git/config '[core]' + assertFileRegex home-files/.config/git/config 'pager = .*/diff-highlight.*less' + assertFileContains home-files/.config/git/config '[interactive]' + assertFileRegex home-files/.config/git/config 'diffFilter = .*/diff-highlight' + ''; +} diff --git a/tests/modules/programs/diff-highlight/diff-highlight-with-git-integration.nix b/tests/modules/programs/diff-highlight/diff-highlight-with-git-integration.nix new file mode 100644 index 00000000..674329e4 --- /dev/null +++ b/tests/modules/programs/diff-highlight/diff-highlight-with-git-integration.nix @@ -0,0 +1,20 @@ +{ + programs.diff-highlight = { + enable = true; + enableGitIntegration = true; + pagerOpts = [ + "--tabs=4" + "-RFX" + ]; + }; + + programs.git.enable = true; + + nmt.script = '' + assertFileExists home-files/.config/git/config + assertFileContains home-files/.config/git/config '[core]' + assertFileRegex home-files/.config/git/config 'pager = .*/diff-highlight.*less' + assertFileContains home-files/.config/git/config '[interactive]' + assertFileRegex home-files/.config/git/config 'diffFilter = .*/diff-highlight' + ''; +}