forked from mirrors/nixpkgs
Merge pull request #29927 from WilliButz/fix-pgjwt-test
nixos/tests: fix pgjwt test
This commit is contained in:
commit
0625110d1a
|
@ -1,42 +1,42 @@
|
||||||
import ./make-test.nix ({ pkgs, ...} :
|
import ./make-test.nix ({ pkgs, lib, ...}:
|
||||||
let
|
let
|
||||||
test = pkgs.writeText "test.sql" ''
|
test = with pkgs; runCommand "patch-test" {
|
||||||
CREATE EXTENSION pgcrypto;
|
nativeBuildInputs = [ pgjwt ];
|
||||||
CREATE EXTENSION pgjwt;
|
}
|
||||||
select sign('{"sub":"1234567890","name":"John Doe","admin":true}', 'secret');
|
''
|
||||||
select * from verify('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9.TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ', 'secret');
|
sed -e '12 i CREATE EXTENSION pgcrypto;\nCREATE EXTENSION pgtap;\nSET search_path TO tap,public;' ${pgjwt.src}/test.sql > $out;
|
||||||
'';
|
'';
|
||||||
in
|
in
|
||||||
{
|
with pkgs; {
|
||||||
name = "pgjwt";
|
name = "pgjwt";
|
||||||
meta = with pkgs.stdenv.lib.maintainers; {
|
meta = with lib.maintainers; {
|
||||||
maintainers = [ spinus ];
|
maintainers = [ spinus willibutz ];
|
||||||
};
|
};
|
||||||
|
|
||||||
nodes = {
|
nodes = {
|
||||||
master =
|
master = { pkgs, config, ... }:
|
||||||
{ pkgs, config, ... }:
|
{
|
||||||
|
services.postgresql = {
|
||||||
{
|
enable = true;
|
||||||
services.postgresql = let mypg = pkgs.postgresql95; in {
|
package = postgresql96;
|
||||||
enable = true;
|
extraPlugins = [ pgjwt pgtap ];
|
||||||
package = mypg;
|
initialScript = writeText "postgresql-init.sql"
|
||||||
extraPlugins =[pkgs.pgjwt];
|
''
|
||||||
initialScript = pkgs.writeText "postgresql-init.sql"
|
CREATE ROLE postgres WITH superuser login createdb;
|
||||||
''
|
'';
|
||||||
CREATE ROLE postgres WITH superuser login createdb;
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
testScript = ''
|
testScript = { nodes, ... }:
|
||||||
|
let
|
||||||
|
sqlSU = "${nodes.master.config.services.postgresql.superUser}";
|
||||||
|
pgProve = "${pkgs.perlPackages.TAPParserSourceHandlerpgTAP}";
|
||||||
|
in
|
||||||
|
''
|
||||||
startAll;
|
startAll;
|
||||||
$master->waitForUnit("postgresql");
|
$master->waitForUnit("postgresql");
|
||||||
$master->succeed("timeout 10 bash -c 'while ! psql postgres -c \"SELECT 1;\";do sleep 1;done;'");
|
$master->copyFileFromHost("${test}","/tmp/test.sql");
|
||||||
$master->succeed("cat ${test} | psql postgres");
|
$master->succeed("${pkgs.sudo}/bin/sudo -u ${sqlSU} PGOPTIONS=--search_path=tap,public ${pgProve}/bin/pg_prove -d postgres -v -f /tmp/test.sql");
|
||||||
# I can't make original test working :[
|
|
||||||
# $master->succeed("${pkgs.perlPackages.TAPParserSourceHandlerpgTAP}/bin/pg_prove -d postgres ${pkgs.pgjwt.src}/test.sql");
|
|
||||||
|
|
||||||
'';
|
'';
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
{ stdenv, fetchFromGitHub }:
|
{ stdenv, fetchFromGitHub }:
|
||||||
stdenv.mkDerivation rec {
|
stdenv.mkDerivation rec {
|
||||||
name = "pgjwt-${version}";
|
name = "pgjwt-${version}";
|
||||||
version = "0.0.1";
|
version = "unstable-2017-04-24";
|
||||||
src = fetchFromGitHub {
|
src = fetchFromGitHub {
|
||||||
owner = "michelp";
|
owner = "michelp";
|
||||||
repo = "pgjwt";
|
repo = "pgjwt";
|
||||||
rev = "12a41eef15e6d3a22399e03178560d5174d496a3";
|
rev = "546a2911027b716586e241be7fd4c6f1785237cd";
|
||||||
sha256 = "1dgx7kqkf9d7j5qj3xykx238xm8jg0s6c8h7zyl4lx8dmbz9sgsv";
|
sha256 = "1riz0xvwb6y02j0fljbr9hcbqb2jqs4njlivmavy9ysbcrrv1vrf";
|
||||||
};
|
};
|
||||||
dontBuild = true;
|
dontBuild = true;
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
|
|
32
pkgs/servers/sql/postgresql/pgtap/default.nix
Normal file
32
pkgs/servers/sql/postgresql/pgtap/default.nix
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
{ stdenv, fetchFromGitHub, postgresql, perl, perlPackages, which }:
|
||||||
|
|
||||||
|
stdenv.mkDerivation rec {
|
||||||
|
name = "pgtap-${version}";
|
||||||
|
version = "0.97.0";
|
||||||
|
|
||||||
|
src = fetchFromGitHub {
|
||||||
|
owner = "theory";
|
||||||
|
repo = "pgtap";
|
||||||
|
rev = "v${version}";
|
||||||
|
sha256 = "1vzc8pxzi0rbywmrvx7i5awngsvzcz75i4jl9bk2vqr223chax6f";
|
||||||
|
};
|
||||||
|
|
||||||
|
nativeBuildInputs = [ postgresql perl perlPackages.TAPParserSourceHandlerpgTAP which ];
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
install -D {sql/pgtap--${version}.sql,pgtap.control} -t $out/share/extension
|
||||||
|
'';
|
||||||
|
|
||||||
|
meta = with stdenv.lib; {
|
||||||
|
description = "pgTAP is a unit testing framework for PostgreSQL";
|
||||||
|
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 = http://pgtap.org;
|
||||||
|
inherit (postgresql.meta) platforms;
|
||||||
|
};
|
||||||
|
}
|
|
@ -2479,6 +2479,8 @@ with pkgs;
|
||||||
|
|
||||||
pgjwt = callPackage ../servers/sql/postgresql/pgjwt {};
|
pgjwt = callPackage ../servers/sql/postgresql/pgjwt {};
|
||||||
|
|
||||||
|
pgtap = callPackage ../servers/sql/postgresql/pgtap {};
|
||||||
|
|
||||||
pigz = callPackage ../tools/compression/pigz { };
|
pigz = callPackage ../tools/compression/pigz { };
|
||||||
|
|
||||||
pixz = callPackage ../tools/compression/pixz { };
|
pixz = callPackage ../tools/compression/pixz { };
|
||||||
|
|
|
@ -12857,11 +12857,11 @@ let self = _self // overrides; _self = with self; {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
TAPParserSourceHandlerpgTAP = buildPerlModule {
|
TAPParserSourceHandlerpgTAP = buildPerlModule rec {
|
||||||
name = "TAP-Parser-SourceHandler-pgTAP-3.30";
|
name = "TAP-Parser-SourceHandler-pgTAP-3.33";
|
||||||
src = fetchurl {
|
src = fetchurl {
|
||||||
url = mirror://cpan/authors/id/D/DW/DWHEELER/TAP-Parser-SourceHandler-pgTAP-3.30.tar.gz;
|
url = "mirror://cpan/authors/id/D/DW/DWHEELER/${name}.tar.gz";
|
||||||
sha256 = "08gadqf898r23sx07sn13555cp9zkwp8igjlh1fza2ycfivpfl9f";
|
sha256 = "35q46y2hbp2ij5n9ir76lmspqj3n8gb0z9l5ipb5g7q90l160m4k";
|
||||||
};
|
};
|
||||||
meta = {
|
meta = {
|
||||||
homepage = http://search.cpan.org/dist/Tap-Parser-Sourcehandler-pgTAP/;
|
homepage = http://search.cpan.org/dist/Tap-Parser-Sourcehandler-pgTAP/;
|
||||||
|
|
Loading…
Reference in a new issue