aboutsummaryrefslogtreecommitdiff
path: root/nixpkgs/nixos/tests/ihatemoney.nix
diff options
context:
space:
mode:
authorKatharina Fey <kookie@spacekookie.de>2020-03-24 10:15:32 +0100
committerKatharina Fey <kookie@spacekookie.de>2020-03-24 10:15:32 +0100
commit96f063dd321abc80ecaa156226cfb7cf9540315a (patch)
tree7a53ef61484fc7bfff6419b1fd635c67199f27d2 /nixpkgs/nixos/tests/ihatemoney.nix
parentaf58f08d3d524e7b008b73a8497ea710915ffaf1 (diff)
parentd96bd3394b734487d1c3bfbac0e8f17465e03afe (diff)
Merge commit 'd96bd3394b734487d1c3bfbac0e8f17465e03afe'
Diffstat (limited to 'nixpkgs/nixos/tests/ihatemoney.nix')
-rw-r--r--nixpkgs/nixos/tests/ihatemoney.nix59
1 files changed, 31 insertions, 28 deletions
diff --git a/nixpkgs/nixos/tests/ihatemoney.nix b/nixpkgs/nixos/tests/ihatemoney.nix
index 14db17fe5e6..7df0ea0b691 100644
--- a/nixpkgs/nixos/tests/ihatemoney.nix
+++ b/nixpkgs/nixos/tests/ihatemoney.nix
@@ -1,13 +1,5 @@
-{ system ? builtins.currentSystem
-, config ? {}
-, pkgs ? import ../.. { inherit system config; }
-}:
-
let
- inherit (import ../lib/testing.nix { inherit system pkgs; }) makeTest;
-in
-map (
- backend: makeTest {
+ f = backend: import ./make-test-python.nix ({ pkgs, ... }: {
name = "ihatemoney-${backend}";
machine = { lib, ... }: {
services.ihatemoney = {
@@ -30,23 +22,34 @@ map (
};
};
testScript = ''
- $machine->waitForOpenPort(8000);
- $machine->waitForUnit("uwsgi.service");
- my $return = $machine->succeed("curl -X POST http://localhost:8000/api/projects -d 'name=yay&id=yay&password=yay&contact_email=yay\@example.com'");
- die "wrong project id $return" unless "\"yay\"\n" eq $return;
- my $timestamp = $machine->succeed("stat --printf %Y /var/lib/ihatemoney/secret_key");
- my $owner = $machine->succeed("stat --printf %U:%G /var/lib/ihatemoney/secret_key");
- die "wrong ownership for the secret key: $owner, is uwsgi running as the right user ?" unless $owner eq "ihatemoney:ihatemoney";
- $machine->shutdown();
- $machine->start();
- $machine->waitForOpenPort(8000);
- $machine->waitForUnit("uwsgi.service");
- # check that the database is really persistent
- print $machine->succeed("curl --basic -u yay:yay http://localhost:8000/api/projects/yay");
- # check that the secret key is really persistent
- my $timestamp2 = $machine->succeed("stat --printf %Y /var/lib/ihatemoney/secret_key");
- die unless $timestamp eq $timestamp2;
- $machine->succeed("curl http://localhost:8000 | grep ihatemoney");
+ machine.wait_for_open_port(8000)
+ machine.wait_for_unit("uwsgi.service")
+
+ assert '"yay"' in machine.succeed(
+ "curl -X POST http://localhost:8000/api/projects -d 'name=yay&id=yay&password=yay&contact_email=yay\@example.com'"
+ )
+ owner, timestamp = machine.succeed(
+ "stat --printf %U:%G___%Y /var/lib/ihatemoney/secret_key"
+ ).split("___")
+ assert "ihatemoney:ihatemoney" == owner
+
+ with subtest("Restart machine and service"):
+ machine.shutdown()
+ machine.start()
+ machine.wait_for_open_port(8000)
+ machine.wait_for_unit("uwsgi.service")
+
+ with subtest("check that the database is really persistent"):
+ machine.succeed("curl --basic -u yay:yay http://localhost:8000/api/projects/yay")
+
+ with subtest("check that the secret key is really persistent"):
+ timestamp2 = machine.succeed("stat --printf %Y /var/lib/ihatemoney/secret_key")
+ assert timestamp == timestamp2
+
+ assert "ihatemoney" in machine.succeed("curl http://localhost:8000")
'';
- }
-) [ "sqlite" "postgresql" ]
+ });
+in {
+ ihatemoney-sqlite = f "sqlite";
+ ihatemoney-postgresql = f "postgresql";
+}