aboutsummaryrefslogtreecommitdiff
path: root/home-manager/tests/modules/programs/fish
diff options
context:
space:
mode:
Diffstat (limited to 'home-manager/tests/modules/programs/fish')
-rw-r--r--home-manager/tests/modules/programs/fish/default.nix5
-rw-r--r--home-manager/tests/modules/programs/fish/functions.nix48
-rw-r--r--home-manager/tests/modules/programs/fish/no-functions.nix22
-rw-r--r--home-manager/tests/modules/programs/fish/plugins.nix60
4 files changed, 135 insertions, 0 deletions
diff --git a/home-manager/tests/modules/programs/fish/default.nix b/home-manager/tests/modules/programs/fish/default.nix
new file mode 100644
index 00000000000..99fe8136700
--- /dev/null
+++ b/home-manager/tests/modules/programs/fish/default.nix
@@ -0,0 +1,5 @@
+{
+ fish-functions = ./functions.nix;
+ fish-no-functions = ./no-functions.nix;
+ fish-plugins = ./plugins.nix;
+}
diff --git a/home-manager/tests/modules/programs/fish/functions.nix b/home-manager/tests/modules/programs/fish/functions.nix
new file mode 100644
index 00000000000..424d0a288c7
--- /dev/null
+++ b/home-manager/tests/modules/programs/fish/functions.nix
@@ -0,0 +1,48 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+let
+
+ func = pkgs.writeText "func.fish" ''
+ function func
+ echo "Hello"
+ end
+ '';
+
+ funcEvent = pkgs.writeText "func-event.fish" ''
+ function func-event --on-event="fish_command_not_found"
+ echo "Not found!"
+ end
+ '';
+
+in {
+ config = {
+ programs.fish = {
+ enable = true;
+
+ functions = {
+ func = ''echo "Hello"'';
+ func-event = {
+ body = ''echo "Not found!"'';
+ onEvent = "fish_command_not_found";
+ };
+ };
+ };
+
+ nmt = {
+ description =
+ "if fish.function is set, check file exists and contents match";
+ script = ''
+ assertFileExists home-files/.config/fish/functions/func.fish
+ echo ${func}
+ assertFileContent home-files/.config/fish/functions/func.fish ${func}
+
+ assertFileExists home-files/.config/fish/functions/func-event.fish
+ echo ${funcEvent}
+ assertFileContent home-files/.config/fish/functions/func-event.fish ${funcEvent}
+ '';
+
+ };
+ };
+}
diff --git a/home-manager/tests/modules/programs/fish/no-functions.nix b/home-manager/tests/modules/programs/fish/no-functions.nix
new file mode 100644
index 00000000000..c817b388953
--- /dev/null
+++ b/home-manager/tests/modules/programs/fish/no-functions.nix
@@ -0,0 +1,22 @@
+{ config, lib, ... }:
+
+with lib;
+
+{
+ config = {
+ programs.fish = {
+ enable = true;
+
+ functions = { };
+ };
+
+ nmt = {
+ description =
+ "if fish.functions is blank, the functions folder should not exist.";
+ script = ''
+ assertPathNotExists home-files/.config/fish/functions
+ '';
+
+ };
+ };
+}
diff --git a/home-manager/tests/modules/programs/fish/plugins.nix b/home-manager/tests/modules/programs/fish/plugins.nix
new file mode 100644
index 00000000000..657c33f39bf
--- /dev/null
+++ b/home-manager/tests/modules/programs/fish/plugins.nix
@@ -0,0 +1,60 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+let
+
+ fooPluginSrc = pkgs.writeText "fooPluginSrc" "";
+
+ generatedConfdFile = pkgs.writeText "plugin-foo.fish" ''
+ # Plugin foo
+ set -l plugin_dir ${fooPluginSrc}
+
+ # Set paths to import plugin components
+ if test -d $plugin_dir/functions
+ set fish_function_path $fish_function_path[1] $plugin_dir/functions $fish_function_path[2..-1]
+ end
+
+ if test -d $plugin_dir/completions
+ set fish_complete_path $fish_complete_path[1] $plugin_dir/completions $fish_complete_path[2..-1]
+ end
+
+ # Source initialization code if it exists.
+ if test -d $plugin_dir/conf.d
+ for f in $plugin_dir/conf.d/*.fish
+ source $f
+ end
+ end
+
+ if test -f $plugin_dir/key_bindings.fish
+ source $plugin_dir/key_bindings.fish
+ end
+
+ if test -f $plugin_dir/init.fish
+ source $plugin_dir/init.fish
+ end
+ '';
+
+in {
+ config = {
+ programs.fish = {
+ enable = true;
+
+ plugins = [{
+ name = "foo";
+ src = fooPluginSrc;
+ }];
+ };
+
+ nmt = {
+ description =
+ "if fish.plugins set, check conf.d file exists and contents match";
+ script = ''
+ assertDirectoryExists home-files/.config/fish/conf.d
+ assertFileExists home-files/.config/fish/conf.d/plugin-foo.fish
+ assertFileContent home-files/.config/fish/conf.d/plugin-foo.fish ${generatedConfdFile}
+ '';
+
+ };
+ };
+}