tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
lol
0
fork
atom
overview
issues
pulls
pipelines
nixos tests: run postgresql tests with postgres user
Rodney Lorrimar
8 years ago
0b027720
502a272e
+10
-8
1 changed file
expand all
collapse all
unified
split
nixos
tests
postgresql.nix
+10
-8
nixos/tests/postgresql.nix
···
26
26
{
27
27
services.postgresql.package=postgresql-package;
28
28
services.postgresql.enable = true;
29
29
-
services.postgresql.initialScript = pkgs.writeText "init.sql" ''
30
30
-
CREATE USER root WITH SUPERUSER;
31
31
-
'';
32
29
};
33
30
34
31
testScript = ''
32
32
+
sub check_count {
33
33
+
my ($select, $nlines) = @_;
34
34
+
return 'test $(sudo -u postgres psql postgres -tAc "' . $select . '"|wc -l) -eq ' . $nlines;
35
35
+
}
36
36
+
35
37
$machine->start;
36
38
$machine->waitForUnit("postgresql");
37
39
# postgresql should be available just after unit start
38
38
-
$machine->succeed("cat ${test-sql} | psql postgres");
40
40
+
$machine->succeed("cat ${test-sql} | sudo -u postgres psql");
39
41
$machine->shutdown; # make sure that postgresql survive restart (bug #1735)
40
42
sleep(2);
41
43
$machine->start;
42
44
$machine->waitForUnit("postgresql");
43
43
-
$machine->fail('test $(psql postgres -tAc "SELECT * FROM sth;"|wc -l) -eq 3');
44
44
-
$machine->succeed('test $(psql postgres -tAc "SELECT * FROM sth;"|wc -l) -eq 5');
45
45
-
$machine->fail('test $(psql postgres -tAc "SELECT * FROM sth;"|wc -l) -eq 4');
46
46
-
$machine->succeed('test $(psql postgres -tAc "SELECT xpath(\'/test/text()\', doc) FROM xmltest;"|wc -l) -eq 1');
45
45
+
$machine->fail(check_count("SELECT * FROM sth;", 3));
46
46
+
$machine->succeed(check_count("SELECT * FROM sth;", 5));
47
47
+
$machine->fail(check_count("SELECT * FROM sth;", 4));
48
48
+
$machine->succeed(check_count("SELECT xpath(\'/test/text()\', doc) FROM xmltest;", 1));
47
49
$machine->shutdown;
48
50
'';
49
51