1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-08 19:46:05 +01:00

tests/diff-highlight: add

Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
This commit is contained in:
Austin Horstman 2025-10-16 21:11:43 -05:00
parent 7d03d5fb73
commit 486487b5e9
4 changed files with 74 additions and 0 deletions

View file

@ -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;
}

View file

@ -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'
'';
}

View file

@ -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'
'';
}

View file

@ -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'
'';
}