diff --git a/tests/modules/programs/man/assertion.nix b/tests/modules/programs/man/assertion.nix new file mode 100644 index 000000000..4c0fdb97b --- /dev/null +++ b/tests/modules/programs/man/assertion.nix @@ -0,0 +1,15 @@ +{ + config = { + test.asserts.assertions.expected = [ + '' + man-db and mandoc can't be used as the man page viewer at the same time! + '' + ]; + + programs.man = { + enable = true; + man-db.enable = true; + mandoc.enable = true; + }; + }; +} diff --git a/tests/modules/programs/man/default.nix b/tests/modules/programs/man/default.nix index 9b066db73..64a4e03bb 100644 --- a/tests/modules/programs/man/default.nix +++ b/tests/modules/programs/man/default.nix @@ -2,6 +2,11 @@ { man-apropos = ./apropos.nix; + man-assertion = ./assertion.nix; + man-disabled-man-db = ./disabled-man-db.nix; + man-disabled-mandoc = ./disabled-mandoc.nix; + man-extra-config = ./extra-config.nix; + man-mandoc = ./mandoc.nix; man-no-manpath = ./no-manpath.nix; man-no-caches-without-package = ./no-caches-without-package.nix; } diff --git a/tests/modules/programs/man/disabled-man-db.nix b/tests/modules/programs/man/disabled-man-db.nix new file mode 100644 index 000000000..f5dccf63d --- /dev/null +++ b/tests/modules/programs/man/disabled-man-db.nix @@ -0,0 +1,14 @@ +{ + config = { + programs.man = { + enable = false; + man-db.enable = true; + mandoc.enable = false; + generateCaches = true; + }; + + nmt.script = '' + assertPathNotExists home-files/.manpath + ''; + }; +} diff --git a/tests/modules/programs/man/disabled-mandoc.nix b/tests/modules/programs/man/disabled-mandoc.nix new file mode 100644 index 000000000..c16efba97 --- /dev/null +++ b/tests/modules/programs/man/disabled-mandoc.nix @@ -0,0 +1,31 @@ +{ + config = { + programs.man = { + enable = false; + man-db.enable = false; + mandoc.enable = true; + generateCaches = true; + }; + + test.stubs = { + mandoc = { + outPath = null; + buildScript = '' + mkdir -p $out/bin + touch $out/bin/{man,makewhatis} + chmod +x $out/bin/* + ''; + }; + }; + + nmt.script = '' + hmSessVars=home-path/etc/profile.d/hm-session-vars.sh + + assertPathNotExists home-files/.manpath + assertPathNotExists home-files/.local/share/mandoc/man + + assertFileExists "$hmSessVars" + assertFileNotRegex "$hmSessVars" 'MANPATH=' + ''; + }; +} diff --git a/tests/modules/programs/man/extra-config.nix b/tests/modules/programs/man/extra-config.nix new file mode 100644 index 000000000..caad03763 --- /dev/null +++ b/tests/modules/programs/man/extra-config.nix @@ -0,0 +1,24 @@ +{ lib, options, ... }: + +{ + config = { + test.asserts.warnings.expected = [ + "The option `programs.man.extraConfig' defined in ${lib.showFiles options.programs.man.extraConfig.files} has been renamed to `programs.man.man-db.extraConfig'." + ]; + + programs.man = { + enable = true; + generateCaches = true; + extraConfig = '' + MANDATORY_MANPATH /usr/man + SECTION 1 n l 8 + ''; + }; + + nmt.script = '' + assertFileExists home-files/.manpath + assertFileContains home-files/.manpath 'MANDATORY_MANPATH /usr/man' + assertFileContains home-files/.manpath 'SECTION 1 n l 8' + ''; + }; +} diff --git a/tests/modules/programs/man/mandoc.nix b/tests/modules/programs/man/mandoc.nix new file mode 100644 index 000000000..6fa1d5039 --- /dev/null +++ b/tests/modules/programs/man/mandoc.nix @@ -0,0 +1,31 @@ +{ + config = { + programs.man = { + enable = true; + man-db.enable = false; + mandoc.enable = true; + generateCaches = true; + }; + + test.stubs = { + mandoc = { + outPath = null; + buildScript = '' + mkdir -p $out/bin + touch $out/bin/{man,makewhatis} + chmod +x $out/bin/* + ''; + }; + }; + + nmt.script = '' + hmSessVars=home-path/etc/profile.d/hm-session-vars.sh + + assertLinkExists home-files/.local/share/mandoc/man + + assertFileExists $hmSessVars + assertFileContains $hmSessVars \ + 'export MANPATH="/home/hm-user/.local/share/mandoc/man''${MANPATH:+:}$MANPATH"' + ''; + }; +}