1 import ./make-test-python.nix ({ pkgs, lib, ... }:
3 journal = pkgs.writeText "test.journal" ''
7 2010/01/10 NixOS Foundation donation
14 meta.maintainers = with lib.maintainers; [ marijanp ];
17 server = { config, pkgs, ... }: {
18 services.hledger-web = {
24 networking.firewall.allowedTCPPorts = [ config.services.hledger-web.port ];
25 systemd.services.hledger-web.preStart = ''
26 ln -s ${journal} /var/lib/hledger-web/.hledger.journal
29 apiserver = { ... }: {
31 services.hledger-web.serveApi = true;
38 server.wait_for_unit("hledger-web.service")
39 server.wait_for_open_port(5000)
40 with subtest("Check if web UI is accessible"):
41 page = server.succeed("curl -L http://127.0.0.1:5000")
42 assert ".hledger.journal" in page
44 apiserver.wait_for_unit("hledger-web.service")
45 apiserver.wait_for_open_port(5000)
46 with subtest("Check if the JSON API is served"):
47 transactions = apiserver.succeed("curl -L http://127.0.0.1:5000/transactions")
48 assert "NixOS Foundation donation" in transactions