mirror of
https://github.com/nix-community/home-manager.git
synced 2025-11-08 11:36:05 +01:00
tests/difftastic: add
Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
This commit is contained in:
parent
111329b475
commit
4166d4e163
6 changed files with 128 additions and 0 deletions
7
tests/modules/programs/difftastic/default.nix
Normal file
7
tests/modules/programs/difftastic/default.nix
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
difftastic-basic = ./difftastic-basic.nix;
|
||||
difftastic-with-git-integration = ./difftastic-with-git-integration.nix;
|
||||
difftastic-with-git-external-diff = ./difftastic-with-git-external-diff.nix;
|
||||
difftastic-with-git-difftool = ./difftastic-with-git-difftool.nix;
|
||||
difftastic-migration = ./difftastic-migration.nix;
|
||||
}
|
||||
18
tests/modules/programs/difftastic/difftastic-basic.nix
Normal file
18
tests/modules/programs/difftastic/difftastic-basic.nix
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
programs.difftastic = {
|
||||
enable = true;
|
||||
options = {
|
||||
color = "always";
|
||||
display = "side-by-side";
|
||||
};
|
||||
};
|
||||
programs.git.enable = true;
|
||||
|
||||
nmt.script = ''
|
||||
# Git config should NOT contain difftastic configuration since git.enable is false by default
|
||||
assertFileExists home-files/.config/git/config
|
||||
assertFileNotRegex home-files/.config/git/config 'external = .*/difft'
|
||||
assertFileNotRegex home-files/.config/git/config 'tool = "difftastic"'
|
||||
assertFileNotRegex home-files/.config/git/config '\[difftool "difftastic"\]'
|
||||
'';
|
||||
}
|
||||
31
tests/modules/programs/difftastic/difftastic-migration.nix
Normal file
31
tests/modules/programs/difftastic/difftastic-migration.nix
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
{
|
||||
lib,
|
||||
options,
|
||||
...
|
||||
}:
|
||||
|
||||
{
|
||||
programs.git = {
|
||||
enable = true;
|
||||
difftastic = {
|
||||
enable = true;
|
||||
options = {
|
||||
color = "always";
|
||||
display = "side-by-side";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
test.asserts.warnings.expected = [
|
||||
"The option `programs.git.difftastic.options' defined in ${lib.showFiles options.programs.git.difftastic.options.files} has been renamed to `programs.difftastic.options'."
|
||||
"The option `programs.git.difftastic.enable' defined in ${lib.showFiles options.programs.git.difftastic.enable.files} has been renamed to `programs.difftastic.enable'."
|
||||
"`programs.difftastic.git.enable` automatic enablement is deprecated. Please explicitly set `programs.difftastic.git.enable = true`."
|
||||
];
|
||||
|
||||
nmt.script = ''
|
||||
# Git config should contain difftastic configuration (backward compatibility)
|
||||
assertFileExists home-files/.config/git/config
|
||||
assertFileContains home-files/.config/git/config '[diff]'
|
||||
assertFileRegex home-files/.config/git/config 'external = .*/difft.*--color.*--display'
|
||||
'';
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
programs.difftastic = {
|
||||
enable = true;
|
||||
git = {
|
||||
enable = true;
|
||||
diffToolMode = true;
|
||||
};
|
||||
options = {
|
||||
color = "always";
|
||||
display = "side-by-side";
|
||||
};
|
||||
};
|
||||
|
||||
programs.git.enable = true;
|
||||
|
||||
nmt.script = ''
|
||||
assertFileExists home-files/.config/git/config
|
||||
assertFileContains home-files/.config/git/config '[diff]'
|
||||
# Should have BOTH diff.external AND difftool config when diffToolMode is true
|
||||
assertFileRegex home-files/.config/git/config 'external = .*/difft.*--color.*--display'
|
||||
assertFileRegex home-files/.config/git/config 'tool = "difftastic"'
|
||||
assertFileContains home-files/.config/git/config '[difftool "difftastic"]'
|
||||
assertFileRegex home-files/.config/git/config 'cmd = .*/difft.*--color.*--display.*\$LOCAL \$REMOTE'
|
||||
'';
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
programs.difftastic = {
|
||||
enable = true;
|
||||
git = {
|
||||
enable = true;
|
||||
diffToolMode = false;
|
||||
};
|
||||
options = {
|
||||
color = "always";
|
||||
display = "side-by-side";
|
||||
};
|
||||
};
|
||||
|
||||
programs.git.enable = true;
|
||||
|
||||
nmt.script = ''
|
||||
assertFileExists home-files/.config/git/config
|
||||
assertFileContains home-files/.config/git/config '[diff]'
|
||||
# Should have diff.external set
|
||||
assertFileRegex home-files/.config/git/config 'external = .*/difft.*--color.*--display'
|
||||
# Should NOT have difftool config when diffToolMode is explicitly false
|
||||
assertFileNotRegex home-files/.config/git/config 'tool = "difftastic"'
|
||||
assertFileNotRegex home-files/.config/git/config '\[difftool "difftastic"\]'
|
||||
'';
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
programs.difftastic = {
|
||||
enable = true;
|
||||
git.enable = true;
|
||||
options = {
|
||||
color = "always";
|
||||
display = "side-by-side";
|
||||
};
|
||||
};
|
||||
|
||||
programs.git.enable = true;
|
||||
|
||||
nmt.script = ''
|
||||
assertFileExists home-files/.config/git/config
|
||||
assertFileContains home-files/.config/git/config '[diff]'
|
||||
# Should have diff.external set
|
||||
assertFileRegex home-files/.config/git/config 'external = .*/difft.*--color.*--display'
|
||||
# Should NOT have difftool config since diffToolMode is false
|
||||
assertFileNotRegex home-files/.config/git/config 'tool = "difftastic"'
|
||||
assertFileNotRegex home-files/.config/git/config '\[difftool "difftastic"\]'
|
||||
'';
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue