aboutsummaryrefslogtreecommitdiff
path: root/tests/modules/programs/fish
diff options
context:
space:
mode:
authorRyan Orendorff <ryan@orendorff.io>2019-09-30 00:11:36 -0700
committerRobert Helgesson <robert@rycee.net>2020-02-20 00:03:26 +0100
commit111011b2c29243a41363e9f71ce29c93cd74c20f (patch)
treee29b7e6501ac9434dfebf6afcbe9a384b58e20b4 /tests/modules/programs/fish
parent108259925a68a4c8c36e3fdf43c39a6ae55b11a7 (diff)
fish: add some tests
- If a function is defined, check that the function file exists and that the contents matches a given string. - If no functions exists, the functions folder should not exist. - Verify plugin functionality.
Diffstat (limited to 'tests/modules/programs/fish')
-rw-r--r--tests/modules/programs/fish/default.nix5
-rw-r--r--tests/modules/programs/fish/functions.nix32
-rw-r--r--tests/modules/programs/fish/no-functions.nix22
-rw-r--r--tests/modules/programs/fish/plugins.nix58
4 files changed, 117 insertions, 0 deletions
diff --git a/tests/modules/programs/fish/default.nix b/tests/modules/programs/fish/default.nix
new file mode 100644
index 00000000000..99fe8136700
--- /dev/null
+++ b/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/tests/modules/programs/fish/functions.nix b/tests/modules/programs/fish/functions.nix
new file mode 100644
index 00000000000..b939a208696
--- /dev/null
+++ b/tests/modules/programs/fish/functions.nix
@@ -0,0 +1,32 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+let
+
+ func = pkgs.writeText "func.fish" ''
+ function func
+ echo "Hello"
+ end
+ '';
+
+in {
+ config = {
+ programs.fish = {
+ enable = true;
+
+ functions = { func = ''echo "Hello"''; };
+ };
+
+ 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}
+ '';
+
+ };
+ };
+}
diff --git a/tests/modules/programs/fish/no-functions.nix b/tests/modules/programs/fish/no-functions.nix
new file mode 100644
index 00000000000..c817b388953
--- /dev/null
+++ b/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/tests/modules/programs/fish/plugins.nix b/tests/modules/programs/fish/plugins.nix
new file mode 100644
index 00000000000..cd675f8b062
--- /dev/null
+++ b/tests/modules/programs/fish/plugins.nix
@@ -0,0 +1,58 @@
+{ 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_function_path[1] $plugin_dir"/completions" $fish_complete_path[2..-1]
+ end
+
+ # Source initialization code if it exists.
+ if test -d $plugin_dir"/conf.d"
+ source $plugin_dir"/conf.d/*.fish"
+ 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}
+ '';
+
+ };
+ };
+}