PG_TAPGEN(1p)
π 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,--dbnameDBNAME β database to which to connect-U,--usernameUSERNAME β username with which to connect-h,--hostHOST β host to which to connect-p,--portPORT β 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β includeCREATE EXTENSION pgtapstatement--no-create-extensionβ excludeCREATE EXTENSION pgtapstatement--directoryDIRECTORY β 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 π
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
- debian trixie: libtap-parser-sourcehandler-pgtap-perl 3.37-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libtap-parser-sourcehandler-pgtap-perl 3.37-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libtap-parser-sourcehandler-pgtap-perl 3.37-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms