2024-01-02 11:29:13 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
|
|
|
, perl
|
|
|
|
, perlPackages
|
|
|
|
, postgresql
|
|
|
|
, postgresqlTestHook
|
|
|
|
, which
|
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2024-02-07 01:22:34 +00:00
|
|
|
stdenv.mkDerivation (finalAttrs: {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "pgtap";
|
2024-04-21 15:54:59 +00:00
|
|
|
version = "1.3.3";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "theory";
|
|
|
|
repo = "pgtap";
|
2024-02-07 01:22:34 +00:00
|
|
|
rev = "v${finalAttrs.version}";
|
2024-04-21 15:54:59 +00:00
|
|
|
sha256 = "sha256-YgvfLGF7pLVcCKD66NnWAydDxtoYHH1DpLiYTEKHJ0E=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [ postgresql perl perlPackages.TAPParserSourceHandlerpgTAP which ];
|
|
|
|
|
|
|
|
installPhase = ''
|
2024-02-07 01:22:34 +00:00
|
|
|
install -D {sql/pgtap--${finalAttrs.version}.sql,pgtap.control} -t $out/share/postgresql/extension
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2024-01-02 11:29:13 +00:00
|
|
|
passthru.tests.extension = stdenv.mkDerivation {
|
|
|
|
name = "pgtap-test";
|
|
|
|
dontUnpack = true;
|
|
|
|
doCheck = true;
|
2024-02-07 01:22:34 +00:00
|
|
|
nativeCheckInputs = [ postgresqlTestHook (postgresql.withPackages (_: [ finalAttrs.finalPackage ])) ];
|
2024-01-02 11:29:13 +00:00
|
|
|
passAsFile = [ "sql" ];
|
|
|
|
sql = ''
|
|
|
|
CREATE EXTENSION pgtap;
|
|
|
|
|
|
|
|
BEGIN;
|
|
|
|
SELECT plan(1);
|
|
|
|
SELECT pass('Test passed');
|
|
|
|
SELECT * FROM finish();
|
|
|
|
ROLLBACK;
|
|
|
|
'';
|
|
|
|
failureHook = "postgresqlStop";
|
|
|
|
checkPhase = ''
|
|
|
|
runHook preCheck
|
|
|
|
psql -a -v ON_ERROR_STOP=1 -f $sqlPath
|
|
|
|
runHook postCheck
|
|
|
|
'';
|
|
|
|
installPhase = "touch $out";
|
|
|
|
};
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2020-11-03 02:18:15 +00:00
|
|
|
description = "A unit testing framework for PostgreSQL";
|
2020-04-24 23:36:52 +00:00
|
|
|
longDescription = ''
|
|
|
|
pgTAP is a unit testing framework for PostgreSQL written in PL/pgSQL and PL/SQL.
|
|
|
|
It includes a comprehensive collection of TAP-emitting assertion functions,
|
|
|
|
as well as the ability to integrate with other TAP-emitting test frameworks.
|
|
|
|
It can also be used in the xUnit testing style.
|
|
|
|
'';
|
|
|
|
maintainers = with maintainers; [ willibutz ];
|
|
|
|
homepage = "https://pgtap.org";
|
|
|
|
inherit (postgresql.meta) platforms;
|
|
|
|
license = licenses.mit;
|
|
|
|
};
|
2024-02-07 01:22:34 +00:00
|
|
|
})
|