Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit testing data with pgTAP #3202

Closed
wjiangFEC opened this issue Jun 8, 2018 · 2 comments
Closed

Unit testing data with pgTAP #3202

wjiangFEC opened this issue Jun 8, 2018 · 2 comments
Assignees
Milestone

Comments

@wjiangFEC
Copy link

FEC team paring with @vrajmohan to learn pgTAP utility for unit testing data.

@vrajmohan
Copy link
Contributor

Created a test. Walked through the test code with some of the team. Opened a PR purely for review - #3268.

@vrajmohan
Copy link
Contributor

Notes from meeting (thanks, @lbeaufort):
PG tap - unit testing. Can test:

  • schema is correct
  • queries are correct
  • sp’s are correct
  • Queries performed within time limit

It’s cumbersome to use.

It makes sense to put your tests where your code is - SQLalchemy - pytest, SQL MV’s, PGtap on the SQL side

Filing amendment chain view - Vraj was already familiar with

real_efile.reps

Put all the tests between
BEGIN/ROLLBACK

So you don’t mess with the data, and tests can be independent.

Awkward thing - you need to say how many assertions you’re going to make. Line 2 - plan(6) - 6 assertions.

pg_prove -d fectest sql/efiling_amendment_chain.sql

pg_prove is command line tool that allows you to run the tests

PG Tap is very strongly typed - you need to cast your expected results. It looks like you need to cast ::numeric or ::varchar - precision doesn’t seem important, but the base type is.

Two types of assertions - check to see what you’ve inserted is there, OR you can look for a pattern.
Oh yeah, if you’re testing a MV you need to refresh it after the insert

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants