forked from mirrors/nixpkgs
postgresqlTestHook: run postgresqlTestSetupPost hook after setting up
This commit is contained in:
parent
a5088fdb72
commit
0ea2d480e4
|
@ -46,6 +46,12 @@ Bash-only variables:
|
||||||
- `postgresqlEnableTCP`: set to `1` to enable TCP listening. Flaky; not recommended.
|
- `postgresqlEnableTCP`: set to `1` to enable TCP listening. Flaky; not recommended.
|
||||||
- `postgresqlStartCommands`: defaults to `pg_ctl start`.
|
- `postgresqlStartCommands`: defaults to `pg_ctl start`.
|
||||||
|
|
||||||
|
## Hooks {#sec-postgresqlTestHook-hooks}
|
||||||
|
|
||||||
|
A number of additional hooks are ran in postgresqlTestHook
|
||||||
|
|
||||||
|
- `postgresqlTestSetupPost`: ran after postgresql has been set up.
|
||||||
|
|
||||||
## TCP and the Nix sandbox {#sec-postgresqlTestHook-tcp}
|
## TCP and the Nix sandbox {#sec-postgresqlTestHook-tcp}
|
||||||
|
|
||||||
`postgresqlEnableTCP` relies on network sandboxing, which is not available on macOS and some custom Nix installations, resulting in flaky tests.
|
`postgresqlEnableTCP` relies on network sandboxing, which is not available on macOS and some custom Nix installations, resulting in flaky tests.
|
||||||
|
|
|
@ -71,6 +71,8 @@ EOF
|
||||||
header 'setting up postgresql'
|
header 'setting up postgresql'
|
||||||
eval "$postgresqlTestSetupCommands"
|
eval "$postgresqlTestSetupCommands"
|
||||||
|
|
||||||
|
runHook postgresqlTestSetupPost
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
postgresqlStop() {
|
postgresqlStop() {
|
||||||
|
|
|
@ -14,6 +14,9 @@ stdenv.mkDerivation {
|
||||||
INSERT INTO hello VALUES ('it '||'worked');
|
INSERT INTO hello VALUES ('it '||'worked');
|
||||||
SELECT * FROM hello;
|
SELECT * FROM hello;
|
||||||
'';
|
'';
|
||||||
|
postgresqlTestSetupPost = ''
|
||||||
|
TEST_POST_HOOK_RAN=1
|
||||||
|
'';
|
||||||
checkPhase = ''
|
checkPhase = ''
|
||||||
runHook preCheck
|
runHook preCheck
|
||||||
psql <$sqlPath | grep 'it worked'
|
psql <$sqlPath | grep 'it worked'
|
||||||
|
@ -21,7 +24,7 @@ stdenv.mkDerivation {
|
||||||
runHook postCheck
|
runHook postCheck
|
||||||
'';
|
'';
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
[[ $TEST_RAN == 1 ]]
|
[[ $TEST_RAN == 1 && $TEST_POST_HOOK_RAN == 1 ]]
|
||||||
touch $out
|
touch $out
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue