-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
230 additions
and
199 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,24 @@ | ||
name: Tests | ||
|
||
on: push | ||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
tests: | ||
test: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
pg-version: ['13', '14', '15', '16', '17'] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Run tests | ||
run: | | ||
./test.sh 15 | ||
- uses: actions/checkout@v4 | ||
- uses: cachix/install-nix-action@v13 | ||
with: | ||
nix_path: nixpkgs=channel:nixos-unstable | ||
- name: Run tests | ||
run: nix-shell --run "vault-with-pg-${{ matrix.pg-version }} make installcheck" | ||
- if: ${{ failure() }} | ||
run: cat regression.diffs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
results/ | ||
regression.* | ||
*.o | ||
*.so | ||
*.bc | ||
*.dylib |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ lib, stdenv, fetchFromGitHub, postgresql, perl, perlPackages, which }: | ||
|
||
stdenv.mkDerivation rec { | ||
pname = "pgtap"; | ||
version = "1.2.0"; | ||
|
||
src = fetchFromGitHub { | ||
owner = "theory"; | ||
repo = "pgtap"; | ||
rev = "v${version}"; | ||
hash = "sha256-lb0PRffwo6J5a6Hqw1ggvn0cW7gPZ02OEcLPi9ineI8="; | ||
}; | ||
|
||
nativeBuildInputs = [ postgresql perl perlPackages.TAPParserSourceHandlerpgTAP which ]; | ||
|
||
installPhase = '' | ||
install -D {sql/pgtap--${version}.sql,pgtap.control} -t $out/share/postgresql/extension | ||
''; | ||
|
||
meta = with lib; { | ||
description = "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; [ samrose ]; | ||
homepage = "https://pgtap.org"; | ||
inherit (postgresql.meta) platforms; | ||
license = licenses.mit; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
select no_plan(); | ||
no_plan | ||
--------- | ||
(0 rows) | ||
|
||
do $$ | ||
select vault.create_secret ( | ||
's3kr3t_k3y', 'a_name', 'this is the foo secret key'); | ||
$$; | ||
ERROR: syntax error at or near "select" | ||
LINE 2: select vault.create_secret ( | ||
^ | ||
SELECT results_eq( | ||
$$ | ||
SELECT decrypted_secret = 's3kr3t_k3y', description = 'this is the foo secret key' | ||
FROM vault.decrypted_secrets WHERE name = 'a_name'; | ||
$$, | ||
$$VALUES (true, true)$$, | ||
'can select from masking view with custom key'); | ||
results_eq | ||
----------------------------------------------------------------- | ||
not ok 1 - can select from masking view with custom key + | ||
# Failed test 1: "can select from masking view with custom key"+ | ||
# Results differ beginning at row 1: + | ||
# have: NULL + | ||
# want: (t,t) | ||
(1 row) | ||
|
||
SELECT lives_ok( | ||
$test$ | ||
select vault.update_secret( | ||
(select id from vault.secrets where name = 'a_name'), new_name:='a_new_name', | ||
new_secret:='new_s3kr3t_k3y', new_description:='this is the bar key') | ||
$test$, | ||
'can update name, secret and description' | ||
); | ||
lives_ok | ||
------------------------------------------------ | ||
ok 2 - can update name, secret and description | ||
(1 row) | ||
|
||
TRUNCATE vault.secrets; | ||
set role bob; | ||
do $$ | ||
select vault.create_secret ('foo', 'bar', 'baz'); | ||
$$; | ||
ERROR: syntax error at or near "select" | ||
LINE 2: select vault.create_secret ('foo', 'bar', 'baz'); | ||
^ | ||
select results_eq( | ||
$test$ | ||
SELECT (decrypted_secret COLLATE "default"), name, description FROM vault.decrypted_secrets | ||
WHERE name = 'bar' | ||
$test$, | ||
$results$values ('foo', 'bar', 'baz')$results$, | ||
'bob can query a secret'); | ||
results_eq | ||
------------------------------------------- | ||
not ok 3 - bob can query a secret + | ||
# Failed test 3: "bob can query a secret"+ | ||
# Results differ beginning at row 1: + | ||
# have: NULL + | ||
# want: (foo,bar,baz) | ||
(1 row) | ||
|
||
select lives_ok( | ||
$test$ | ||
select vault.update_secret( | ||
(select id from vault.secrets where name = 'bar'), | ||
'fooz', | ||
'barz', | ||
'bazz') | ||
$test$, | ||
'bob can update a secret'); | ||
lives_ok | ||
-------------------------------- | ||
ok 4 - bob can update a secret | ||
(1 row) | ||
|
||
select results_eq( | ||
$test$ | ||
SELECT (decrypted_secret COLLATE "default"), name, description | ||
FROM vault.decrypted_secrets | ||
$test$, | ||
$results$values ('fooz', 'barz', 'bazz')$results$, | ||
'bob can query an updated secret'); | ||
results_eq | ||
---------------------------------------------------- | ||
not ok 5 - bob can query an updated secret + | ||
# Failed test 5: "bob can query an updated secret"+ | ||
# Results differ beginning at row 1: + | ||
# have: NULL + | ||
# want: (fooz,barz,bazz) | ||
(1 row) | ||
|
||
select * from finish(); | ||
finish | ||
-------------------------------------- | ||
1..5 | ||
# Looks like you failed 3 tests of 5 | ||
(2 rows) | ||
|
Oops, something went wrong.