Questions tagged [pgtap]

Suite of database functions to write TAP-emitting unit tests in psql scripts or xUnit-style test functions

18 questions
5
votes
1 answer

pgtap: expected and obtained result are equal, yet the test fails

i use pgtap to test postgresql stored procedures. its results_eq function takes the result of a stored procedure, compares it to an expected result and reports failure if both are not equal. this is the code i am running: PREPARE result_have AS…
ssc
  • 9,528
  • 10
  • 64
  • 94
3
votes
1 answer

Number of columns or their types differ between the queries

Using PostgreSQL 9.4.3 on Debian Jessie 64. question.sql : \set client_min_messages = debug BEGIN; SELECT * from no_plan(); SELECT Dugong.Users_Add('Sarit','thisispassword','programmer'); SELECT is(Dugong.Users_isExist('Sarit'),'t', 'Test…
joe
  • 8,383
  • 13
  • 61
  • 109
2
votes
1 answer

How to install pgTAP on Windows?

I have been trying to install pgTAP on Windows for hours and could not figure it out. Does anyone know how to do it? Thanks. UPDATE: I installed strawberry perl and GnuWin32 in order to run Makefile. Here are some of the errors I got: make 'awk' is…
Xin
  • 737
  • 3
  • 10
  • 27
1
vote
1 answer

How do I set the database password for pg_prove in PgTAP?

Just getting started with pgTAP, I'm using a localhost running docker container server. How do I tell pgTAP what the password for that server is? I don't see anything mentioned in the documentation.
xenoterracide
  • 16,274
  • 24
  • 118
  • 243
1
vote
1 answer

Postgresql return nested set of values in stored procedure

I'm currently doing a test in PostgreSQL using PGTAP. In order to minimize redundancy in my code I placed duplicate code inside a function. I have functions that both returns a SETOF TEXT. CREATE FUNCTION _create_common_test( this_argument …
0
votes
1 answer

array from a `setof text` and array constructed from string are failing to equate

I have a function that returns setof text. I have a pgtap test that compares two values using pgtap's is comparitor: return next is( ARRAY(select shared_types()), '{"{level,field_lookup,field_data,levels_insert_return}"}', ' The…
Edmund's Echo
  • 766
  • 8
  • 15
0
votes
0 answers

Checking data migration with pgTAP

I have two tables, A and B: A: id, counter_1 B: id, counter_2 Let's assume that some data migration has proceeded, so that B.counter_2 becomes B.counter_2 + A.counter_1 (id's matching), that is, B.counter_2 = B.counter_2 + A.counter_1 Is there any…
Mikhail Sibirev
  • 101
  • 1
  • 3
0
votes
1 answer

Use postgres Pgtap with logical operators

I am testing my supabase table using pgtap and supabase test helpers I have a table posts with a creator uuid and a published boolean field. My row level policy checks that creators of a post are always allowed to see it, regardless if published or…
JoJota
  • 35
  • 10
0
votes
1 answer

Is it possible to use uppercase strings in pgTap without it assuming it's a prepared statement?

We're attempting to run tests against a postgres function that returns a SETOF VARCHAR uppercase strings. Whenever this test case runs, however, pgTap tries to look up a prepared statement with the same name as the uppercase value we're expecting to…
Alex
  • 743
  • 7
  • 17
0
votes
1 answer

Postgres: How to transform data in two cursors before comparison?

I am replacing a legacy function get_data in our database which takes some entity_id and returns a refcursor. I am writing a new function get_data_new which is using different data sources, but the outputs are expected to be the same as get_data for…
nicstella
  • 298
  • 2
  • 9
0
votes
0 answers

How to test the PostgreSQL script with mock data?

How to create the following tests: I have a PostgreSQL script. I want the test to create mock data, call the script on these tables and create the resulting table from the mock data and compare this result with some expected result table that I have…
mirkap
  • 7
  • 1
  • 4
0
votes
1 answer

query has no destination for result data pg tap postgres sql

I have a simple unit test to run in the pgtab https://pgtap.org/documentation.html#is as shown below BEGIN; SELECT plan(12); -- Run the tests. do $$ declare v_expected varchar(100);; begin SELECT…
San Jaisy
  • 15,327
  • 34
  • 171
  • 290
0
votes
1 answer

Postgres extension missing after upgrade

I have just upgraded my development postgres cluster from postgreSQL 9.6 to 11. Everything went fine except that I got an error around the pgtap extension that I use for unit testing. Now when I try to restore a database I'm getting an error "ERROR:…
DatabaseShouter
  • 814
  • 9
  • 11
0
votes
1 answer

pg_prove run test case and output junit xml style result

What is the command to let the pg_prove run test case and output the result to Junit xml style? pg_prove -U ubuntu -d $DB database/test/all_database_tests.sql Can we use --formatter TAP::Formatter::JUnit or --harness TAP::Harness::JUnit to format…
jackchen
  • 71
  • 8
0
votes
1 answer

How to test PROCEDURE in PostgreSQL with pgTAP?

Is there a best practice for unit testing a PostgreSQL 11+ PROCEDURE (NOT a FUNCTION) using pgTap. For example, how would one recommend unit testing a stored procedure like this: CREATE OR REPLACE PROCEDURE foo.do_something(IN i_value…
akagixxer
  • 1,767
  • 3
  • 21
  • 35
1
2