diff options
author | Marijan Petričević <marijan.petricevic94@gmail.com> | 2020-01-20 12:34:57 +0100 |
---|---|---|
committer | Marijan Petričević <marijan.petricevic94@gmail.com> | 2021-01-28 15:29:53 +0100 |
commit | f56089ded5e3895d9fbd82bfbdff79b761e42118 (patch) | |
tree | 41b783450a844d710b814bc9693ab2a70950c933 /nixos/tests | |
parent | d439e559ef6692a0ef37c8f6f3341476ce529bb8 (diff) |
nixos/hledger-web: init module and test
Diffstat (limited to 'nixos/tests')
-rw-r--r-- | nixos/tests/all-tests.nix | 1 | ||||
-rw-r--r-- | nixos/tests/hledger-web.nix | 53 |
2 files changed, 54 insertions, 0 deletions
diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 05fd5c4822a7b..d267ddeb4cf4e 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -155,6 +155,7 @@ in # not on other platforms. hibernate = handleTestOn ["x86_64-linux"] ./hibernate.nix {}; hitch = handleTest ./hitch {}; + hledger-web = handleTest ./hledger-web.nix {}; hocker-fetchdocker = handleTest ./hocker-fetchdocker {}; home-assistant = handleTest ./home-assistant.nix {}; hostname = handleTest ./hostname.nix {}; diff --git a/nixos/tests/hledger-web.nix b/nixos/tests/hledger-web.nix new file mode 100644 index 0000000000000..378d819437db0 --- /dev/null +++ b/nixos/tests/hledger-web.nix @@ -0,0 +1,53 @@ +import ./make-test-python.nix ({ pkgs, lib, ... }: +let + journal = pkgs.writeText "test.journal" '' + 2010/01/10 Loan + assets:cash 500$ + income:loan -500$ + 2010/01/10 NixOS Foundation donation + expenses:donation 250$ + assets:cash -250$ + ''; +in +rec { + name = "hledger-web"; + meta.maintainers = with lib.maintainers; [ marijanp ]; + + nodes = { + server = { config, pkgs, ... }: rec { + services.hledger-web = { + host = "127.0.0.1"; + port = 5000; + enable = true; + journalFile = journal; + }; + networking.firewall.allowedTCPPorts = [ services.hledger-web.port ]; + }; + apiserver = { config, pkgs, ... }: rec { + services.hledger-web = { + host = "127.0.0.1"; + port = 5000; + enable = true; + serveApi = true; + journalFile = journal; + }; + networking.firewall.allowedTCPPorts = [ services.hledger-web.port ]; + }; + }; + + testScript = '' + start_all() + + server.wait_for_unit("hledger-web.service") + server.wait_for_open_port(5000) + with subtest("Check if web UI is accessible"): + page = server.succeed("curl -L http://127.0.0.1:5000") + assert "test.journal" in page + + apiserver.wait_for_unit("hledger-web.service") + apiserver.wait_for_open_port(5000) + with subtest("Check if the JSON API is served"): + transactions = apiserver.succeed("curl -L http://127.0.0.1:5000/transactions") + assert "NixOS Foundation donation" in transactions + ''; +}) |