From 2c40948c7316d624ea3eb40574432dbfe9ab1ec2 Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Mon, 10 Jun 2024 20:15:18 +0300 Subject: [PATCH] nixosTests.taskchampion-sync-server: init --- nixos/tests/all-tests.nix | 1 + nixos/tests/taskchampion-sync-server.nix | 48 ++++++++++++++++++++++++ pkgs/by-name/ta/taskwarrior3/package.nix | 3 ++ 3 files changed, 52 insertions(+) create mode 100644 nixos/tests/taskchampion-sync-server.nix diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 12f8954c4040..1b2f1e1530ec 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -993,6 +993,7 @@ in { tandoor-recipes-script-name = handleTest ./tandoor-recipes-script-name.nix {}; tang = handleTest ./tang.nix {}; taskserver = handleTest ./taskserver.nix {}; + taskchampion-sync-server = handleTest ./taskchampion-sync-server.nix {}; tayga = handleTest ./tayga.nix {}; technitium-dns-server = handleTest ./technitium-dns-server.nix {}; teeworlds = handleTest ./teeworlds.nix {}; diff --git a/nixos/tests/taskchampion-sync-server.nix b/nixos/tests/taskchampion-sync-server.nix new file mode 100644 index 000000000000..42dfb0cbeca3 --- /dev/null +++ b/nixos/tests/taskchampion-sync-server.nix @@ -0,0 +1,48 @@ +import ./make-test-python.nix ( + { ... }: + { + name = "taskchampion-sync-server"; + + nodes = { + server = { + services.taskchampion-sync-server.enable = true; + services.taskchampion-sync-server.openFirewall = true; + }; + client = + { pkgs, ... }: + { + environment.systemPackages = [ pkgs.taskwarrior3 ]; + }; + }; + testScript = + { nodes, ... }: + let + cfg = nodes.server.services.taskchampion-sync-server; + port = builtins.toString cfg.port; + # Generated with uuidgen + uuid = "bf01376e-04a4-435a-9263-608567531af3"; + password = "nixos-test"; + in + '' + # Explicitly start the VMs so that we don't accidentally start newServer + server.start() + client.start() + + server.wait_for_unit("taskchampion-sync-server.service") + server.wait_for_open_port(${port}) + + # See man task-sync(5) + client.succeed("mkdir ~/.task") + client.succeed("touch ~/.taskrc") + client.succeed("echo sync.server.origin=http://server:${port} >> ~/.taskrc") + client.succeed("echo sync.server.client_id=${uuid} >> ~/.taskrc") + client.succeed("echo sync.encryption_secret=${password} >> ~/.taskrc") + client.succeed("task add hello world") + client.succeed("task sync") + + # Useful for debugging + client.copy_from_vm("/root/.task", "client") + server.copy_from_vm("${cfg.dataDir}", "server") + ''; + } +) diff --git a/pkgs/by-name/ta/taskwarrior3/package.nix b/pkgs/by-name/ta/taskwarrior3/package.nix index 1b27cb3a410c..26b8d8ecd32c 100644 --- a/pkgs/by-name/ta/taskwarrior3/package.nix +++ b/pkgs/by-name/ta/taskwarrior3/package.nix @@ -8,6 +8,7 @@ fetchFromGitHub, cmake, libuuid, + nixosTests, python3, xdg-utils, installShellFiles, @@ -75,6 +76,8 @@ stdenv.mkDerivation rec { ln -s $out/share/vim-plugins/task $out/share/nvim/site ''; + passthru.tests.nixos = nixosTests.taskchampion-sync-server; + meta = { changelog = "https://github.com/GothenburgBitFactory/taskwarrior/blob/${src.rev}/ChangeLog"; description = "Highly flexible command-line tool to manage TODO lists";