From 93335810751f0404fe424e61ad58bc8e94bf8e9d Mon Sep 17 00:00:00 2001 From: natsukium Date: Sat, 29 Oct 2022 10:47:06 +0900 Subject: [PATCH] vscode: add userTasks test --- tests/modules/programs/vscode/default.nix | 1 + tests/modules/programs/vscode/tasks.nix | 43 +++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 tests/modules/programs/vscode/tasks.nix diff --git a/tests/modules/programs/vscode/default.nix b/tests/modules/programs/vscode/default.nix index 607758269..4015121d5 100644 --- a/tests/modules/programs/vscode/default.nix +++ b/tests/modules/programs/vscode/default.nix @@ -1,4 +1,5 @@ { vscode-keybindings = ./keybindings.nix; + vscode-tasks = ./tasks.nix; vscode-update-checks = ./update-checks.nix; } diff --git a/tests/modules/programs/vscode/tasks.nix b/tests/modules/programs/vscode/tasks.nix new file mode 100644 index 000000000..f0d283805 --- /dev/null +++ b/tests/modules/programs/vscode/tasks.nix @@ -0,0 +1,43 @@ +{ pkgs, config, ... }: + +let + + tasksFilePath = if pkgs.stdenv.hostPlatform.isDarwin then + "Library/Application Support/Code/User/tasks.json" + else + ".config/Code/User/tasks.json"; + + tasks = { + version = "2.0.0"; + tasks = [{ + type = "shell"; + label = "Hello task"; + command = "hello"; + }]; + }; + + expectedTasks = pkgs.writeText "tasks-expected.json" '' + { + "tasks": [ + { + "command": "hello", + "label": "Hello task", + "type": "shell" + } + ], + "version": "2.0.0" + } + ''; + +in { + programs.vscode = { + enable = true; + package = pkgs.writeScriptBin "vscode" "" // { pname = "vscode"; }; + userTasks = tasks; + }; + + nmt.script = '' + assertFileExists "home-files/${tasksFilePath}" + assertFileContent "home-files/${tasksFilePath}" "${expectedTasks}" + ''; +}