Skip to content

Commit

Permalink
nix: move withtmpdb to separate file
Browse files Browse the repository at this point in the history
Co-authored-by: Remo Rechkemmer <59358383+monacoremo@users.noreply.github.com>
  • Loading branch information
wolfgangwalther and monacoremo committed Apr 12, 2021
1 parent f99fd6c commit 579a626
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 21 deletions.
5 changes: 4 additions & 1 deletion default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,13 @@ rec {
nixpkgsUpgrade =
pkgs.callPackage nix/nixpkgs-upgrade.nix { };

withTmpDb =
pkgs.callPackage nix/withtmpdb.nix { };

# Scripts for running tests.
tests =
pkgs.callPackage nix/tests.nix {
inherit postgrest postgrestProfiled postgresqlVersions devCabalOptions;
inherit postgrest postgrestProfiled postgresqlVersions devCabalOptions withTmpDb;
ghc = pkgs.haskell.compiler."${compiler}";
hpc-codecov = pkgs.haskell.packages."${compiler}".hpc-codecov;
};
Expand Down
21 changes: 1 addition & 20 deletions nix/tests.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,10 @@
, postgrestProfiled
, python3
, runtimeShell
, withTmpDb
, yq
}:
let
# Wrap the `test/with_tmp_db` script with the required dependencies from Nix.
withTmpDb =
postgresql:
checkedShellScript
{
name = "postgrest-test-withtmpdb-${postgresql.name}";
docs = "Run the given command in a temporary database";
inRootDir = true;
}
''
# avoid starting multiple layers of with_tmp_db
if test ! -v PGRST_DB_URI; then
export PATH=${postgresql}/bin:"$PATH"
exec test/with_tmp_db "$@"
else
"$@"
fi
'';

# Create a `withPostgresql` for each PostgreSQL version that we want to test
# against.
withPostgresqlVersions =
Expand Down
20 changes: 20 additions & 0 deletions nix/withtmpdb.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Wrap the `test/with_tmp_db` script with the required dependencies from Nix.
{ checkedShellScript }:

postgresql:
checkedShellScript
{
name = "postgrest-test-withtmpdb-${postgresql.name}";
docs = "Run the given command in a temporary database";
inRootDir = true;
}
''
# avoid starting multiple layers of with_tmp_db
if test ! -v PGRST_DB_URI; then
export PATH=${postgresql}/bin:"$PATH"
exec test/with_tmp_db "$@"
else
"$@"
fi
''

0 comments on commit 579a626

Please sign in to comment.