diff options
author | Jeff Boes | 2009-04-24 15:20:42 +0000 |
---|---|---|
committer | Jeff Boes | 2009-04-24 15:22:46 +0000 |
commit | eb856b289457be6fc5f6dcaaddd29d6cbbdd7bf6 (patch) | |
tree | de2f9410f32a9010ad07be98144246f691ac53a3 | |
parent | ba6148e9ef42690c298dd5f62b98be154129a8ae (diff) |
Tests for settings_checksum
-rw-r--r-- | t/02_settings_checksum.t | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/t/02_settings_checksum.t b/t/02_settings_checksum.t new file mode 100644 index 000000000..a472bcb41 --- /dev/null +++ b/t/02_settings_checksum.t @@ -0,0 +1,56 @@ +#!perl + +## Test the "settings_checksum" action + +use strict; +use warnings; +use Data::Dumper; +use DBI; +use Test::More tests => 8; +use lib 't','.'; +use CP_Testing; + +use vars qw/$dbh $result $t $host $dbname $testtbl $testtrig_prefix/; + +$testtbl = 'test_settings_checksum'; +$testtrig_prefix = 'test_settings_checksum_'; + +my $cp = CP_Testing->new( {default_action => 'settings_checksum'} ); + +$dbh = $cp->test_database_handle(); +$dbname = $cp->get_dbname; +$host = $cp->get_host(); +my $label = 'POSTGRES_SETTINGS_CHECKSUM'; + +my $S = q{Action 'settings_checksum'}; + +$t = qq{$S self-identifies correctly}; +$result = $cp->run('--critical 0'); +like ($result, qr{^$label}, $t); + +$t = qq{$S identifies database}; +like ($result, qr{DB "$dbname"}, $t); + +$t = qq{$S identifies host}; +like ($result, qr{host:$host}, $t); + +my $true_checksum; +$true_checksum = $1 if $result =~ /checksum: ([0-9a-f]{32})/; + +$t = qq{$S reports missing flag}; +is ($cp->run(), qq{ERROR: Must provide a 'warning' or 'critical' option\n}, $t); + +$t = qq{$S rejects -w and -c together}; +is ($cp->run('-w abcdabcdabcdabcdabcdabcdabcdabcd -c abcdabcdabcdabcdabcdabcdabcdabcd'), + qq{ERROR: Can only provide 'warning' OR 'critical' option\n}, $t); + +$t = qq{$S notes mismatched checksum (warning)}; +like ($cp->run('-w abcdabcdabcdabcdabcdabcdabcdabcd'), + qr{$label WARNING: .* checksum:}, $t); + +$t = qq{$S notes mismatched checksum (critical)}; +like ($cp->run('-c abcdabcdabcdabcdabcdabcdabcdabcd'), + qr{$label CRITICAL: .* checksum:}, $t); + +$t = qq{$S accepts matching checksum}; +like ($cp->run("-w $true_checksum"), qr/OK.*\Qchecksum: $true_checksum\E/, $t); |