.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Test::DBIx::Class::SchemaManager::Trait::Testpostgresql 3pm" .TH Test::DBIx::Class::SchemaManager::Trait::Testpostgresql 3pm "2023-01-29" "perl v5.36.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Test::DBIx::Class::SchemaManager::Trait::Testpostgresql \- deploy to a test Postgresql instance .SH "DESCRIPTION" .IX Header "DESCRIPTION" This trait uses Test::Postgresql58 to auto create a test instance of Postgresql in a temporary area. This way you can test against Postgresql without having to create a test database, users, etc. Postgresql needs to be installed (but doesn't need to be running) as well as DBD::Pg. You need to install these yourself. .PP Please review Test::Postgresql58 for help if you get stuck. .SH "CONFIGURATION" .IX Header "CONFIGURATION" This trait supports all the existing features but adds some additional options you can put into your inlined of configuration files. These following additional configuration options basically map to the options supported by Test::Postgresql58 and the docs are adapted shamelessly from that module. .PP For the most part, if you have Postgresql installed in a normal, findable manner you should be able to leave all these options blank. .SS "base_dir" .IX Subsection "base_dir" Returns directory under which the postgresql instance is being created. If you leave this unset we automatically create a place in the temporary directory and then clean it up later. Unless you plan to roundtrip to the same database a lot you can just leave this blank. .PP Please note if you set this to a particular area, we will delete it unless you specifically use the 'keep_db' option. \s-1SO\s0 be care where you point it! .PP Here's an example use. I often want the test database setup in my local testing directory, that makes it easy for me to examine the logs, etc. I do: .PP .Vb 1 \& BASE_DIR=t/tmp KEEP_DB=1 prove \-lv t/my\-postgresql\-test.t .Ve .PP Now I can roundtrip the test as often as I want and in between tests I can review the logs, start the database manually and login (see the 'keep_db' section below for an example of how to do this). Next time I run the tests the framework will automatically clean it up and rest the schema for testing. .PP You may need to do this if you are stuck on a shared host and can't write anything to /tmp. Remember, you can also put the 'base_dir' option into configuration instead of having to type it into the commandline each time! .PP Note that if you override the \s-1BASE_DIR\s0 we will set the 'force_drop_tables' option to true to ensure that we properly clean the database before trying to install tables and fixtures. .SS "initdb and postmaster" .IX Subsection "initdb and postmaster" If your postgresql is not in the \f(CW$PATH\fR you might need to specify the location to one of there binaries. If you have a normal postgresql setup this should not be a problem and you can leave this blank. .PP If you have to set these, please note you need to set the full path to the required file, not just the path to containing directory. .SH "NOTES" .IX Header "NOTES" The following are notes regarding the way this trait alters or extends the core functionality as described in the basic documentation. .SS "keep_db" .IX Subsection "keep_db" If you use the 'keep_db' option, this will preserve the temporarily created database files, however it will not prevent Test::Postgresql58 from stopping the database when you are finished. This is a safety measure, since if we didn't stop a test generated database instance automatically, you could easily end up with many databases running at once, and that could bring your server or testing box to a halt. .PP If you use the 'keep_db' option and want to start and log into the test generated database instance, you can start the database by noticing the diagnostic output that should be generated at the top of your test. It will look similar to: .PP .Vb 3 \& # Starting postgresql with: /Library/PostgreSQL/8.4/bin/postmaster \e \& \-p 15432 \-D /tmp/E4tuZF5uFR/data \& # DBI\->connect(\*(AqDBI:Pg:dbname=template1;port=15432\*(Aq,\*(Aqpostgres\*(Aq,\*(Aq\*(Aq]) .Ve .PP If you have specified the base_dir to use, this output will not be displayed by default. You can force it's display by setting tdbic_debug to true. eg. .PP .Vb 1 \& TDBIC_DEBUG=1 BASE_DIR=t/tmp KEEP_DB=1 prove \-lv t/my\-postgresql\-test.t .Ve .PP You can then start the database instance yourself with something like: .PP .Vb 2 \& ./Library/PostgreSQL/8.4/bin/postmaster \-p 15432 \e \& \-D /tmp/E4tuZF5uFR/data & .Ve .PP You will get output that looks like: .PP .Vb 3 \& [1] 1564 \& LOG: database system is ready to accept connections \& LOG: autovacuum launcher started .Ve .PP There will be some additional output to the term and then the server will go into the background. If you don't like the extra output, you can just redirect it all to /dev/null or whatever is similar for your \s-1OS.\s0 .PP You can now log into the test generated database instance with: .PP .Vb 1 \& psql \-h localhost \-\-user postgres \-\-port 15432 \-d template1 .Ve .PP You may need to specify the full path to 'mysql' if it's not in your search \&\f(CW$PATH\fR. .PP When you are finished you can then kill the process. In this case our reported process id is '1564' .PP .Vb 1 \& kill 1564 .Ve .PP And then you might wish to 'tidy' up temp .PP .Vb 1 \& rm \-rf /tmp/E4tuZF5uFR .Ve .PP All the above assume you are on a unix or unixlike system. Would welcome document patches for how to do all the above on windows. .SS "Noisy warnings" .IX Subsection "Noisy warnings" When running the Test::Postgresql58 instance, you'll probably see a lot of mostly harmless warnings, similar to: .PP .Vb 4 \& NOTICE: drop cascades to 2 other objects \& DETAIL: drop cascades to constraint cd_track_fk_cd_id_fkey on table cd_track \& drop cascades to constraint cd_artist_fk_cd_id_fkey on table cd_artist \& NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "cd_pkey" for table "cd" .Ve .PP In general these are harmless and can be ignored. .PP If you like to avoid these messages, you could change your connect_info like this: .PP .Vb 6 \& connect_info => { \& dsn => \*(Aqdbi:Pg:dbname=dbname\*(Aq, \& user => \*(Aquser\*(Aq, \& pass => \*(Aqsecret\*(Aq, \& on_connect_do => \*(AqSET client_min_messages=WARNING;\*(Aq, \& }, .Ve .SH "AUTHOR" .IX Header "AUTHOR" John Napiorkowski \f(CW\*(C`\*(C'\fR .SH "COPYRIGHT & LICENSE" .IX Header "COPYRIGHT & LICENSE" Copyright 2009, John Napiorkowski \f(CW\*(C`\*(C'\fR .PP This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.