nixos/documize: port test to python

This commit is contained in:
Marijan 2019-11-06 20:48:38 +01:00 committed by Marijan Petricevic
parent e2c20c6230
commit bf816e44c4

View File

@ -1,4 +1,4 @@
import ./make-test.nix ({ pkgs, lib, ...} : { import ./make-test-python.nix ({ pkgs, lib, ...} : {
name = "documize"; name = "documize";
meta = with pkgs.stdenv.lib.maintainers; { meta = with pkgs.stdenv.lib.maintainers; {
maintainers = [ ma27 ]; maintainers = [ ma27 ];
@ -29,30 +29,34 @@ import ./make-test.nix ({ pkgs, lib, ...} : {
}; };
testScript = '' testScript = ''
startAll; start_all()
$machine->waitForUnit("documize-server.service"); machine.wait_for_unit("documize-server.service")
$machine->waitForOpenPort(3000); machine.wait_for_open_port(3000)
my $dbhash = $machine->succeed("curl -f localhost:3000 " dbhash = machine.succeed(
. " | grep 'property=\"dbhash' " "curl -f localhost:3000 | grep 'property=\"dbhash' | grep -Po 'content=\"\\K[^\"]*'"
. " | grep -Po 'content=\"\\K[^\"]*'" )
);
chomp($dbhash); dbhash = dbhash.strip()
$machine->succeed("curl -X POST " machine.succeed(
. "--data 'dbname=documize' " (
. "--data 'dbhash=$dbhash' " "curl -X POST"
. "--data 'title=NixOS' " " --data 'dbname=documize'"
. "--data 'message=Docs' " " --data 'dbhash={}'"
. "--data 'firstname=John' " " --data 'title=NixOS'"
. "--data 'lastname=Doe' " " --data 'message=Docs'"
. "--data 'email=john.doe\@nixos.org' " " --data 'firstname=John'"
. "--data 'password=verysafe' " " --data 'lastname=Doe'"
. "-f localhost:3000/api/setup" " --data 'email=john.doe@nixos.org'"
); " --data 'password=verysafe'"
" -f localhost:3000/api/setup"
).format(dbhash)
)
$machine->succeed('test "$(curl -f localhost:3000/api/public/meta | jq ".title" | xargs echo)" = "NixOS"'); machine.succeed(
'test "$(curl -f localhost:3000/api/public/meta | jq ".title" | xargs echo)" = "NixOS"'
)
''; '';
}) })