From c42206db028b25e689a52c3a74c15397312effdb Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 14 Jan 2019 22:50:11 +0100 Subject: [PATCH] i3: add test of keybinding merge logic --- tests/default.nix | 2 ++ .../window-managers/i3-keybindings.nix | 34 +++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 tests/modules/services/window-managers/i3-keybindings.nix diff --git a/tests/default.nix b/tests/default.nix index 0fd71a8f..f7873f4b 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -20,5 +20,7 @@ import nmt { "git/with-str-extra-config" = ./modules/programs/git-with-str-extra-config.nix; texlive-minimal = ./modules/programs/texlive-minimal.nix; xresources = ./modules/xresources.nix; + } // pkgs.lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux { + "i3/keybindings" = ./modules/services/window-managers/i3-keybindings.nix; }; } diff --git a/tests/modules/services/window-managers/i3-keybindings.nix b/tests/modules/services/window-managers/i3-keybindings.nix new file mode 100644 index 00000000..b5ee4fd8 --- /dev/null +++ b/tests/modules/services/window-managers/i3-keybindings.nix @@ -0,0 +1,34 @@ +{ config, lib, ... }: + +with lib; + +{ + config = { + xsession.windowManager.i3 = { + enable = true; + + config.keybindings = + let + modifier = config.xsession.windowManager.i3.config.modifier; + in + lib.mkOptionDefault { + "${modifier}+Left" = "overridden-command"; + "${modifier}+Right" = null; + "${modifier}+Invented" = "invented-key-command"; + }; + }; + + nmt.script = '' + assertFileExists home-files/.config/i3/config + + assertFileRegex home-files/.config/i3/config \ + 'bindsym Mod1+Left overridden-command' + + assertFileNotRegex home-files/.config/i3/config \ + 'Mod1+Right' + + assertFileRegex home-files/.config/i3/config \ + 'bindsym Mod1+Invented invented-key-command' + ''; + }; +}