From 2c8b96209143ca9889b339d27fb20bc98ac3cf82 Mon Sep 17 00:00:00 2001 From: Austin Horstman Date: Sun, 12 Oct 2025 19:19:33 -0500 Subject: [PATCH] tests/delta: add tests Create a new set of tests to verify the new module's behavior. Signed-off-by: Austin Horstman --- tests/modules/programs/delta/default.nix | 5 +++ tests/modules/programs/delta/delta-basic.nix | 35 +++++++++++++++ .../programs/delta/delta-migration.nix | 45 +++++++++++++++++++ .../delta/delta-with-git-integration.nix | 32 +++++++++++++ 4 files changed, 117 insertions(+) create mode 100644 tests/modules/programs/delta/default.nix create mode 100644 tests/modules/programs/delta/delta-basic.nix create mode 100644 tests/modules/programs/delta/delta-migration.nix create mode 100644 tests/modules/programs/delta/delta-with-git-integration.nix diff --git a/tests/modules/programs/delta/default.nix b/tests/modules/programs/delta/default.nix new file mode 100644 index 00000000..1c98f034 --- /dev/null +++ b/tests/modules/programs/delta/default.nix @@ -0,0 +1,5 @@ +{ + delta-basic = ./delta-basic.nix; + delta-with-git-integration = ./delta-with-git-integration.nix; + delta-migration = ./delta-migration.nix; +} diff --git a/tests/modules/programs/delta/delta-basic.nix b/tests/modules/programs/delta/delta-basic.nix new file mode 100644 index 00000000..62e968d9 --- /dev/null +++ b/tests/modules/programs/delta/delta-basic.nix @@ -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' + ''; +} diff --git a/tests/modules/programs/delta/delta-migration.nix b/tests/modules/programs/delta/delta-migration.nix new file mode 100644 index 00000000..682159cb --- /dev/null +++ b/tests/modules/programs/delta/delta-migration.nix @@ -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"' + ''; +} diff --git a/tests/modules/programs/delta/delta-with-git-integration.nix b/tests/modules/programs/delta/delta-with-git-integration.nix new file mode 100644 index 00000000..17872592 --- /dev/null +++ b/tests/modules/programs/delta/delta-with-git-integration.nix @@ -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"' + ''; +}