fork/home-manager

git clone https://git.julia.blue/fork/home-manager

Robert Helgessontests: some minor cleanupsaf715ed8

master
1.7 KiB78 linesraw
1# Test that keybindings.json is created correctly.
2{ pkgs, ... }:
3
4let
5  bindings = [
6    {
7      key = "ctrl+c";
8      command = "editor.action.clipboardCopyAction";
9      when = "textInputFocus && false";
10    }
11    {
12      key = "ctrl+c";
13      command = "deleteFile";
14      when = "";
15    }
16    {
17      key = "d";
18      command = "deleteFile";
19      when = "explorerViewletVisible";
20    }
21    {
22      key = "ctrl+r";
23      command = "run";
24      args = { command = "echo file"; };
25    }
26  ];
27
28  keybindingsPath = if pkgs.stdenv.hostPlatform.isDarwin then
29    "Library/Application Support/Code/User/keybindings.json"
30  else
31    ".config/Code/User/keybindings.json";
32
33  settingsPath = if pkgs.stdenv.hostPlatform.isDarwin then
34    "Library/Application Support/Code/User/settings.json"
35  else
36    ".config/Code/User/settings.json";
37
38  expectedKeybindings = pkgs.writeText "expected.json" ''
39    [
40      {
41        "command": "editor.action.clipboardCopyAction",
42        "key": "ctrl+c",
43        "when": "textInputFocus && false"
44      },
45      {
46        "command": "deleteFile",
47        "key": "ctrl+c",
48        "when": ""
49      },
50      {
51        "command": "deleteFile",
52        "key": "d",
53        "when": "explorerViewletVisible"
54      },
55      {
56        "args": {
57          "command": "echo file"
58        },
59        "command": "run",
60        "key": "ctrl+r"
61      }
62    ]
63  '';
64
65in {
66  programs.vscode = {
67    enable = true;
68    keybindings = bindings;
69    package = pkgs.writeScriptBin "vscode" "" // { pname = "vscode"; };
70  };
71
72  nmt.script = ''
73    assertFileExists "home-files/${keybindingsPath}"
74    assertFileContent "home-files/${keybindingsPath}" "${expectedKeybindings}"
75
76    assertPathNotExists "home-files/${settingsPath}"
77  '';
78}