From 6b7f6d6ce3f582a28e75701bbbb61daeab188e91 Mon Sep 17 00:00:00 2001 From: Jeff Boes Date: Mon, 8 Jun 2009 11:17:19 -0400 Subject: [PATCH] User, schema, table, sequence, view tests complete --- t/02_same_schema.t | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/t/02_same_schema.t b/t/02_same_schema.t index 455843198..f198fbcd8 100644 --- a/t/02_same_schema.t +++ b/t/02_same_schema.t @@ -6,7 +6,7 @@ use 5.006; use strict; use warnings; use Data::Dumper; -use Test::More tests => 16; +use Test::More tests => 24; use lib 't','.'; use CP_Testing; @@ -58,12 +58,16 @@ like ($cp1->run(qq{--dbhost2=$cp2->{shorthost} --dbuser2=$cp2->{testuser}}), qr{^$label CRITICAL.*Items not matched: 1\b.*Schema in 1 but not 2: schema_1_only}, $t); +$t = qq{$S succeeds when noschema filter used}; +like ($cp1->run(qq{--warning=noschema --dbhost2=$cp2->{shorthost} --dbuser2=$cp2->{testuser}}), qr{^$label OK}, $t); + $t = qq{$S fails when schemas have different owners}; $dbh1->do(q{ALTER SCHEMA schema_1_only OWNER TO alternate_owner}); $dbh2->do(q{CREATE SCHEMA schema_1_only}); like ($cp1->run(qq{--dbhost2=$cp2->{shorthost} --dbuser2=$cp2->{testuser}}), qr{^$label CRITICAL.*Items not matched: 1\b.*Schema schema_1_only owned by alternate_owner}, $t); + $dbh1->do(q{DROP SCHEMA schema_1_only}); $dbh2->do(q{DROP SCHEMA schema_1_only}); @@ -73,6 +77,9 @@ like ($cp1->run(qq{--dbhost2=$cp2->{shorthost} --dbuser2=$cp2->{testuser}}), qr{^$label CRITICAL.*Items not matched: 1\b.*Schema in 2 but not 1: schema_2_only}, $t); +$t = qq{$S succeeds when noschema filter used}; +like ($cp1->run(qq{--warning=noschema --dbhost2=$cp2->{shorthost} --dbuser2=$cp2->{testuser}}), qr{^$label OK}, $t); + $t = qq{$S fails when schemas have different owners}; $dbh2->do(q{ALTER SCHEMA schema_2_only OWNER TO alternate_owner}); $dbh1->do(q{CREATE SCHEMA schema_2_only}); @@ -90,6 +97,9 @@ like ($cp1->run(qq{--dbhost2=$cp2->{shorthost} --dbuser2=$cp2->{testuser}}), qr{^$label CRITICAL.*Items not matched: 1\b.*Table in 1 but not 2: public.table_1_only}, $t); +$t = qq{$S succeeds when notables filter used}; +like ($cp1->run(qq{--warning=notables --dbhost2=$cp2->{shorthost} --dbuser2=$cp2->{testuser}}), qr{^$label OK}, $t); + $t = qq{$S fails when tables have different owners}; $dbh1->do(q{ALTER TABLE table_1_only OWNER TO alternate_owner}); $dbh2->do(q{CREATE TABLE table_1_only (a int)}); @@ -105,6 +115,9 @@ like ($cp1->run(qq{--dbhost2=$cp2->{shorthost} --dbuser2=$cp2->{testuser}}), qr{^$label CRITICAL.*Items not matched: 1\b.*Table in 2 but not 1: public.table_2_only}, $t); +$t = qq{$S succeeds when notables filter used}; +like ($cp1->run(qq{--warning=notables --dbhost2=$cp2->{shorthost} --dbuser2=$cp2->{testuser}}), qr{^$label OK}, $t); + $t = qq{$S fails when tables have different owners}; $dbh2->do(q{ALTER TABLE table_2_only OWNER TO alternate_owner}); $dbh1->do(q{CREATE TABLE table_2_only (a int)}); @@ -114,7 +127,6 @@ like ($cp1->run(qq{--dbhost2=$cp2->{shorthost} --dbuser2=$cp2->{testuser}}), $dbh1->do(q{DROP TABLE table_2_only}); $dbh2->do(q{DROP TABLE table_2_only}); - #/////////// Sequences $t = qq{$S fails when first schema has an extra sequence}; @@ -122,6 +134,10 @@ $dbh1->do(q{CREATE SEQUENCE sequence_1_only}); like ($cp1->run(qq{--dbhost2=$cp2->{shorthost} --dbuser2=$cp2->{testuser}}), qr{^$label CRITICAL.*Items not matched: 1\b.*Sequence in 1 but not 2: public.sequence_1_only}, $t); + +$t = qq{$S succeeds when nosequences filter used}; +like ($cp1->run(qq{--warning=nosequences --dbhost2=$cp2->{shorthost} --dbuser2=$cp2->{testuser}}), qr{^$label OK}, $t); + $dbh1->do(q{DROP SEQUENCE sequence_1_only}); $t = qq{$S fails when second schema has an extra sequence}; @@ -129,6 +145,10 @@ $dbh2->do(q{CREATE SEQUENCE sequence_2_only}); like ($cp1->run(qq{--dbhost2=$cp2->{shorthost} --dbuser2=$cp2->{testuser}}), qr{^$label CRITICAL.*Items not matched: 1\b.*Sequence in 2 but not 1: public.sequence_2_only}, $t); + +$t = qq{$S succeeds when nosequences filter used}; +like ($cp1->run(qq{--warning=nosequences --dbhost2=$cp2->{shorthost} --dbuser2=$cp2->{testuser}}), qr{^$label OK}, $t); + $dbh2->do(q{DROP SEQUENCE sequence_2_only}); #/////////// Views @@ -138,6 +158,10 @@ $dbh1->do(q{CREATE VIEW view_1_only AS SELECT 1}); like ($cp1->run(qq{--dbhost2=$cp2->{shorthost} --dbuser2=$cp2->{testuser}}), qr{^$label CRITICAL.*Items not matched: 1\b.*View in 1 but not 2: public.view_1_only}, $t); + +$t = qq{$S succeeds when noviews filter used}; +like ($cp1->run(qq{--warning=noviews --dbhost2=$cp2->{shorthost} --dbuser2=$cp2->{testuser}}), qr{^$label OK}, $t); + $dbh1->do(q{DROP VIEW view_1_only}); $t = qq{$S fails when second schema has an extra view}; @@ -145,6 +169,10 @@ $dbh2->do(q{CREATE VIEW view_2_only AS SELECT 1}); like ($cp1->run(qq{--dbhost2=$cp2->{shorthost} --dbuser2=$cp2->{testuser}}), qr{^$label CRITICAL.*Items not matched: 1\b.*View in 2 but not 1: public.view_2_only}, $t); + +$t = qq{$S succeeds when noviews filter used}; +like ($cp1->run(qq{--warning=noviews --dbhost2=$cp2->{shorthost} --dbuser2=$cp2->{testuser}}), qr{^$label OK}, $t); + $dbh2->do(q{DROP VIEW view_2_only}); -- 2.39.5