From 3a8e036f4a01d1e137598bfdc3995b02c4671339 Mon Sep 17 00:00:00 2001 From: Damien Cassou Date: Mon, 1 Jun 2020 10:08:33 +0200 Subject: [PATCH] direnv: add initial test for bash integration (cherry picked from commit 575cd4b8bac4775c724b95224cd5e23d8a2064ef) --- tests/default.nix | 1 + tests/modules/programs/direnv/bash.nix | 17 +++++++++++++++++ tests/modules/programs/direnv/default.nix | 4 ++++ tests/modules/programs/direnv/stdlib.nix | 19 +++++++++++++++++++ 4 files changed, 41 insertions(+) create mode 100644 tests/modules/programs/direnv/bash.nix create mode 100644 tests/modules/programs/direnv/default.nix create mode 100644 tests/modules/programs/direnv/stdlib.nix diff --git a/tests/default.nix b/tests/default.nix index aac1dfee..6c83c8cd 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -30,6 +30,7 @@ import nmt { ./modules/programs/bash ./modules/programs/browserpass ./modules/programs/dircolors + ./modules/programs/direnv ./modules/programs/fish ./modules/programs/git ./modules/programs/gpg diff --git a/tests/modules/programs/direnv/bash.nix b/tests/modules/programs/direnv/bash.nix new file mode 100644 index 00000000..db0d6b39 --- /dev/null +++ b/tests/modules/programs/direnv/bash.nix @@ -0,0 +1,17 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + config = { + programs.bash.enable = true; + programs.direnv.enable = true; + + nmt.script = '' + assertFileExists home-files/.bashrc + assertFileRegex \ + home-files/.bashrc \ + 'eval "\$(/nix/store/.*direnv.*/bin/direnv hook bash)"' + ''; + }; +} diff --git a/tests/modules/programs/direnv/default.nix b/tests/modules/programs/direnv/default.nix new file mode 100644 index 00000000..82ad15ff --- /dev/null +++ b/tests/modules/programs/direnv/default.nix @@ -0,0 +1,4 @@ +{ + direnv-bash = ./bash.nix; + direnv-stdlib = ./stdlib.nix; +} diff --git a/tests/modules/programs/direnv/stdlib.nix b/tests/modules/programs/direnv/stdlib.nix new file mode 100644 index 00000000..1d06a0bc --- /dev/null +++ b/tests/modules/programs/direnv/stdlib.nix @@ -0,0 +1,19 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let expectedContent = "something important"; +in { + config = { + programs.bash.enable = true; + programs.direnv.enable = true; + programs.direnv.stdlib = expectedContent; + + nmt.script = '' + assertFileExists home-files/.bashrc + assertFileRegex \ + home-files/.config/direnv/direnvrc \ + '${expectedContent}' + ''; + }; +}