.\" Automatically generated by Pod::Man 2.25 (Pod::Simple 3.16) .\" .\" 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" '' '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 turned on, 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. .ie \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} .el \{\ . de IX .. .\} .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Test::SQL::Translator 3pm" .TH Test::SQL::Translator 3pm "2012-01-18" "perl v5.14.2" "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::SQL::Translator \- Test::More test functions for the Schema objects. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& # t/magic.t \& \& use FindBin \*(Aq$Bin\*(Aq; \& use Test::More; \& use Test::SQL::Translator; \& \& # Run parse \& my $sqlt = SQL::Translator\->new( \& parser => "Magic", \& filename => "$Bin/data/magic/test.magic", \& ... \& ); \& ... \& my $schema = $sqlt\->schema; \& \& # Test the table it produced. \& table_ok( $schema\->get_table("Customer"), { \& name => "Customer", \& fields => [ \& { \& name => "CustomerID", \& data_type => "INT", \& size => 12, \& default_value => undef, \& is_nullable => 0, \& is_primary_key => 1, \& }, \& { \& name => "bar", \& data_type => "VARCHAR", \& size => 255, \& is_nullable => 0, \& }, \& ], \& constraints => [ \& { \& type => "PRIMARY KEY", \& fields => "CustomerID", \& }, \& ], \& indices => [ \& { \& name => "barindex", \& fields => ["bar"], \& }, \& ], \& }); .Ve .SH "DESCSIPTION" .IX Header "DESCSIPTION" Provides a set of Test::More tests for Schema objects. Testing a parsed schema is then as easy as writing a perl data structure describing how you expect the schema to look. Also provides maybe_plan for conditionally running tests based on their dependencies. .PP The data structures given to the test subs don't have to include all the possible values, only the ones you expect to have changed. Any left out will be tested to make sure they are still at their default value. This is a useful check that you your parser hasn't accidentally set schema values you didn't expect it to. .PP For an example of the output run the t/16xml\-parser.t test. .SH "Tests" .IX Header "Tests" All the tests take a first arg of the schema object to test, followed by a hash ref describing how you expect that object to look (you only need give the attributes you expect to have changed from the default). The 3rd arg is an optional test name to pre-pend to all the generated test names. .SS "table_ok" .IX Subsection "table_ok" .SS "field_ok" .IX Subsection "field_ok" .SS "constraint_ok" .IX Subsection "constraint_ok" .SS "index_ok" .IX Subsection "index_ok" .SS "view_ok" .IX Subsection "view_ok" .SS "trigger_ok" .IX Subsection "trigger_ok" .SS "procedure_ok" .IX Subsection "procedure_ok" .SH "CONDITIONAL TESTS" .IX Header "CONDITIONAL TESTS" The \f(CW\*(C`maybe_plan\*(C'\fR function handles conditionally running an individual test. It is here to enable running the test suite even when dependencies are missing; not having (for example) GraphViz installed should not keep the test suite from passing. .PP \&\f(CW\*(C`maybe_plan\*(C'\fR takes the number of tests to (maybe) run, and a list of modules on which test execution depends: .PP .Vb 1 \& maybe_plan(180, \*(AqSQL::Translator::Parser::MySQL\*(Aq); .Ve .PP If one of \f(CW\*(C`SQL::Translator::Parser::MySQL\*(C'\fR's dependencies does not exist, then the test will be skipped. .SH "EXPORTS" .IX Header "EXPORTS" table_ok, field_ok, constraint_ok, index_ok, view_ok, trigger_ok, procedure_ok, maybe_plan .SH "TODO" .IX Header "TODO" .IP "Test the tests!" 4 .IX Item "Test the tests!" .PD 0 .IP "Test Count Constants" 4 .IX Item "Test Count Constants" .PD Constants to give the number of tests each *_ok sub uses. e.g. How many tests does field_ok run? Can then use these to set up the test plan easily. .IP "Test skipping" 4 .IX Item "Test skipping" As the test subs wrap up lots of tests in one call you can't skip idividual tests only whole sets e.g. a whole table or field. We could add skip_* items to the test hashes to allow per test skips. e.g. .Sp .Vb 1 \& skip_is_primary_key => "Need to fix primary key parsing.", .Ve .IP "yaml test specs" 4 .IX Item "yaml test specs" Maybe have the test subs also accept yaml for the test hash ref as its a much nicer for writing big data structures. We can then define tests as in input schema file and test yaml file to compare it against. .SH "BUGS" .IX Header "BUGS" .SH "AUTHOR" .IX Header "AUTHOR" Mark D. Addison , Darren Chamberlain . .PP Thanks to Ken Y. Clark for the original table and field test code taken from his mysql test. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIperl\fR\|(1), SQL::Translator, SQL::Translator::Schema, Test::More.