tests/delta: add tests
Create a new set of tests to verify the new module's behavior. Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
This commit is contained in:
parent
f436677f5f
commit
2c8b962091
4 changed files with 117 additions and 0 deletions
5
tests/modules/programs/delta/default.nix
Normal file
5
tests/modules/programs/delta/default.nix
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
delta-basic = ./delta-basic.nix;
|
||||
delta-with-git-integration = ./delta-with-git-integration.nix;
|
||||
delta-migration = ./delta-migration.nix;
|
||||
}
|
||||
35
tests/modules/programs/delta/delta-basic.nix
Normal file
35
tests/modules/programs/delta/delta-basic.nix
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
{ config, ... }:
|
||||
|
||||
{
|
||||
programs.delta = {
|
||||
enable = true;
|
||||
package = config.lib.test.mkStubPackage {
|
||||
name = "delta";
|
||||
buildScript = ''
|
||||
mkdir -p $out/bin
|
||||
touch $out/bin/delta
|
||||
chmod 755 $out/bin/delta
|
||||
'';
|
||||
};
|
||||
options = {
|
||||
features = "line-numbers decorations";
|
||||
syntax-theme = "Dracula";
|
||||
decorations = {
|
||||
commit-decoration-style = "bold yellow box ul";
|
||||
file-style = "bold yellow ul";
|
||||
file-decoration-style = "none";
|
||||
};
|
||||
};
|
||||
};
|
||||
programs.git.enable = true;
|
||||
|
||||
nmt.script = ''
|
||||
# Git config should NOT contain delta configuration since enableGitIntegration is false by default
|
||||
assertFileNotRegex home-files/.config/git/config 'pager = .*/bin/delta'
|
||||
assertFileNotRegex home-files/.config/git/config 'diffFilter = .*/bin/delta'
|
||||
|
||||
# Verify the wrapper passes the config flag
|
||||
# The wrapper script should contain --config flag
|
||||
assertFileRegex home-path/bin/delta '\-\-config'
|
||||
'';
|
||||
}
|
||||
45
tests/modules/programs/delta/delta-migration.nix
Normal file
45
tests/modules/programs/delta/delta-migration.nix
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
{
|
||||
lib,
|
||||
options,
|
||||
...
|
||||
}:
|
||||
|
||||
{
|
||||
programs.git = {
|
||||
enable = true;
|
||||
delta = {
|
||||
enable = true;
|
||||
options = {
|
||||
features = "line-numbers decorations";
|
||||
syntax-theme = "Dracula";
|
||||
decorations = {
|
||||
commit-decoration-style = "bold yellow box ul";
|
||||
file-style = "bold yellow ul";
|
||||
file-decoration-style = "none";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
test.asserts.warnings.expected = [
|
||||
"The option `programs.git.delta.options' defined in ${lib.showFiles options.programs.git.delta.options.files} has been renamed to `programs.delta.options'."
|
||||
"The option `programs.git.delta.enable' defined in ${lib.showFiles options.programs.git.delta.enable.files} has been renamed to `programs.delta.enable'."
|
||||
"`programs.delta.enableGitIntegration` automatic enablement is deprecated. Please explicitly set `programs.delta.enableGitIntegration = true`."
|
||||
];
|
||||
|
||||
nmt.script = ''
|
||||
# Git config should contain delta configuration (backward compatibility)
|
||||
assertFileExists home-files/.config/git/config
|
||||
assertFileContains home-files/.config/git/config '[core]'
|
||||
assertFileRegex home-files/.config/git/config 'pager = .*/bin/delta'
|
||||
assertFileContains home-files/.config/git/config '[interactive]'
|
||||
assertFileRegex home-files/.config/git/config 'diffFilter = .*/bin/delta --color-only'
|
||||
assertFileContains home-files/.config/git/config '[delta]'
|
||||
assertFileContains home-files/.config/git/config 'features = "line-numbers decorations"'
|
||||
assertFileContains home-files/.config/git/config 'syntax-theme = "Dracula"'
|
||||
assertFileContains home-files/.config/git/config '[delta "decorations"]'
|
||||
assertFileContains home-files/.config/git/config 'commit-decoration-style = "bold yellow box ul"'
|
||||
assertFileContains home-files/.config/git/config 'file-decoration-style = "none"'
|
||||
assertFileContains home-files/.config/git/config 'file-style = "bold yellow ul"'
|
||||
'';
|
||||
}
|
||||
32
tests/modules/programs/delta/delta-with-git-integration.nix
Normal file
32
tests/modules/programs/delta/delta-with-git-integration.nix
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
{
|
||||
programs.delta = {
|
||||
enable = true;
|
||||
enableGitIntegration = true;
|
||||
options = {
|
||||
features = "line-numbers decorations";
|
||||
syntax-theme = "Dracula";
|
||||
decorations = {
|
||||
commit-decoration-style = "bold yellow box ul";
|
||||
file-style = "bold yellow ul";
|
||||
file-decoration-style = "none";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
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 = .*/bin/delta'
|
||||
assertFileContains home-files/.config/git/config '[interactive]'
|
||||
assertFileRegex home-files/.config/git/config 'diffFilter = .*/bin/delta --color-only'
|
||||
assertFileContains home-files/.config/git/config '[delta]'
|
||||
assertFileContains home-files/.config/git/config 'features = "line-numbers decorations"'
|
||||
assertFileContains home-files/.config/git/config 'syntax-theme = "Dracula"'
|
||||
assertFileContains home-files/.config/git/config '[delta "decorations"]'
|
||||
assertFileContains home-files/.config/git/config 'commit-decoration-style = "bold yellow box ul"'
|
||||
assertFileContains home-files/.config/git/config 'file-decoration-style = "none"'
|
||||
assertFileContains home-files/.config/git/config 'file-style = "bold yellow ul"'
|
||||
'';
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue