summary refs log tree commit diff
path: root/pkgs/build-support/setup-hooks/postgresql-test-hook/test.nix
blob: 6d8ad6c8c7e3395561ef930afe8f30bf5f0b63e2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
{ postgresql, postgresqlTestHook, stdenv }:

stdenv.mkDerivation {
  name = "postgresql-test-hook-test";
  buildInputs = [ postgresqlTestHook ];
  checkInputs = [ postgresql ];
  dontUnpack = true;
  doCheck = true;
  passAsFile = ["sql"];
  sql = ''
    CREATE TABLE hello (
      message text
    );
    INSERT INTO hello VALUES ('it '||'worked');
    SELECT * FROM hello;
  '';
  checkPhase = ''
    runHook preCheck
    psql <$sqlPath | grep 'it worked'
    TEST_RAN=1
    runHook postCheck
  '';
  installPhase = ''
    [[ $TEST_RAN == 1 ]]
    touch $out
  '';
}