1{
2 fetchFromGitHub,
3 lib,
4 perl,
5 perlPackages,
6 postgresql,
7 postgresqlBuildExtension,
8 postgresqlTestHook,
9 stdenv,
10 which,
11}:
12
13postgresqlBuildExtension (finalAttrs: {
14 pname = "pgtap";
15 version = "1.3.3";
16
17 src = fetchFromGitHub {
18 owner = "theory";
19 repo = "pgtap";
20 tag = "v${finalAttrs.version}";
21 hash = "sha256-YgvfLGF7pLVcCKD66NnWAydDxtoYHH1DpLiYTEKHJ0E=";
22 };
23
24 nativeBuildInputs = [
25 perl
26 perlPackages.TAPParserSourceHandlerpgTAP
27 which
28 ];
29
30 passthru.tests.extension = stdenv.mkDerivation {
31 name = "pgtap-test";
32 dontUnpack = true;
33 doCheck = true;
34 nativeCheckInputs = [
35 postgresqlTestHook
36 (postgresql.withPackages (_: [ finalAttrs.finalPackage ]))
37 ];
38 passAsFile = [ "sql" ];
39 sql = ''
40 CREATE EXTENSION pgtap;
41
42 BEGIN;
43 SELECT plan(1);
44 SELECT pass('Test passed');
45 SELECT * FROM finish();
46 ROLLBACK;
47 '';
48 checkPhase = ''
49 runHook preCheck
50 psql -a -v ON_ERROR_STOP=1 -f $sqlPath
51 runHook postCheck
52 '';
53 installPhase = "touch $out";
54 };
55
56 meta = {
57 description = "Unit testing framework for PostgreSQL";
58 longDescription = ''
59 pgTAP is a unit testing framework for PostgreSQL written in PL/pgSQL and PL/SQL.
60 It includes a comprehensive collection of TAP-emitting assertion functions,
61 as well as the ability to integrate with other TAP-emitting test frameworks.
62 It can also be used in the xUnit testing style.
63 '';
64 maintainers = with lib.maintainers; [ willibutz ];
65 homepage = "https://pgtap.org";
66 inherit (postgresql.meta) platforms;
67 license = lib.licenses.mit;
68 };
69})