PG_TAPGEN(1p)

πŸ“¦
version 3.37 Β· 3 versions
, in debian trixie, ubuntu resolute, ubuntu stonking

πŸ’– NAME πŸ’–

pg_tapgen β€” bestie, it generates schema TAP tests from an existing database. That's the whole gig. You point it at a db, it writes the tests for you. Iconic behaviour honestly.


πŸŽ€ USAGE πŸŽ€

pg_tapgen -d template1 > schema_test.sql

🌸 DESCRIPTION 🌸

Okay so pg_tapgen is a command-line utility that generates pgTAP tests to validate a database schema β€” it reads an existing database and generates the tests to match it. The way that it just knows your schema? Obsessed. πŸ’…

To run it, you need DBI and DBD::Pg installed from CPAN or via a package distribution.

⚠️ Warning: these prerequisites are not validated by the pgTAP Makefile, so you'll need to install them yourself. Because of that, inclusion of this script in the pgTAP distribution is experimental. It may be moved to its own distribution in the future. No cap, that's just how it is right now. 🫢

✨ OPTIONS ✨

  • -d, --dbname DBNAME β€” database to which to connect
  • -U, --username USERNAME β€” username with which to connect
  • -h, --host HOST β€” host to which to connect
  • -p, --port PORT β€” port to which to connect
  • -v, --verbose β€” display output of test scripts while running them
  • -N, --exclude-schema β€” exclude a schema from the generated tests
  • -c, --create-extension β€” include CREATE EXTENSION pgtap statement
  • --no-create-extension β€” exclude CREATE EXTENSION pgtap statement
  • --directory DIRECTORY β€” directory to which to write the test files
  • -H, --help β€” print a usage statement and exit
  • -m, --man β€” print the complete documentation and exit
  • -V, --version β€” print the version number and exit

πŸ” OPTIONS DETAILS πŸ”

πŸ’… -d, --dbname

pg_tapgen --dbname try
pg_tapgen -d postgres

The name of the database you're connecting to. Defaults to whatever's in the $PGDATABASE environment variable, or the system username if that's not set. ✨

πŸ¦‹ -U, --username

pg_tapgen --username foo
pg_tapgen -U postgres

The PostgreSQL user name to connect as. Defaults to the $PGUSER environment variable, or the operating system name of the user running the application. And psst β€” the password can be specified with $PGPASSWORD. 🀫

🌈 -h, --host

pg_tapgen --host pg.example.com
pg_tapgen -h dev.local

Specifies the host name of the machine on which the server is running. Little detail that matters: if the value begins with a slash, it's used as the directory for the Unix-domain socket. Defaults to the $PGHOST environment variable or localhost. 🏠

⭐ -p, --port

pg_tapgen --port 1234
pg_tapgen -p 666

Specifies the TCP port, or the local Unix-domain socket file extension, on which the server is listening for connections. Defaults to the $PGPORT environment variable or, if that's not set, to the port specified at compile time β€” usually 5432. πŸšͺ

πŸ“ --dir, --directory

Directory to which to write test files. Defaults to the current directory. Easy. πŸ’–

🧚 -c, --create-extension, --no-create-extension

pg_tapgen --create-exension
pg_tapgen -c
pg_tapgen --no-create-exension

Enable or disable the inclusion of CREATE EXTENSION pgtap; statements in the generated test files. It's enabled by default, so if you want it gone you have to say so. πŸŽ€

πŸ‘‘ -v, --verbose

pg_tapgen --verbose
pg_tapgen -v

Display standard output of test scripts while running them. You can also trigger this behaviour by setting the $TEST_VERBOSE environment variable to a true value. Main character debugging energy fr fr. πŸ”₯

πŸ’€ -N, --exclude-schema

pg_tapgen --exclude-schema contrib
pg_tapgen -N testing -N temporary

Exclude a schema from the test generation. Heads up: pg_tapgen always ignores information_schema, because pgTAP ignores it too. But if there are other schemas in the database that you don't need or don't want to test for (because you run the tests on another database without those schemas, for example), use --exclude-schema to omit them. May be used more than once to exclude more than one schema β€” stack 'em. πŸ™ˆ

🌸 -H, --help

pg_tapgen --help
pg_tapgen -H

Outputs a brief description of the options supported by pg_tapgen and exits.

πŸ’œ -m, --man

pg_tapgen --man
pg_tapgen -m

Outputs this documentation and exits. Hi, you're reading it. 🫢

✨ -V, --version

pg_tapgen --version
pg_tapgen -V

Outputs the program name and version and exits.


πŸ’– AUTHOR πŸ’–

David E. Wheeler <dwheeler@cpan.org>


Copyright (c) 2009-2025 David E. Wheeler. Some Rights Reserved.


And that's the whole page, bestie β€” this was PG_TAPGEN(1p) from the User Contributed Perl Documentation, coming to you as part of perl v5.40.1, dated 2025-04-09. Slay. πŸ’…βœ¨

πŸ“¦ where this page comes from