Changeset 1050 for branches/stable/t/DNSTest.pm
- Timestamp:
- 03/05/26 18:20:36 (17 hours ago)
- Location:
- branches/stable
- Files:
-
- 2 edited
- 1 copied
-
. (modified) (1 prop)
-
t (copied) (copied from trunk/t )
-
t/DNSTest.pm (modified) (3 diffs, 1 prop)
Legend:
- Unmodified
- Added
- Removed
-
branches/stable
- Property svn:mergeinfo changed
/trunk merged: 943-948,957,961,965,971,985
- Property svn:mergeinfo changed
-
branches/stable/t/DNSTest.pm
-
Property svn:keywords
set to
Date Rev Author Id
r943 r1050 21 21 ## 22 22 23 package DNS DB::DNSTest;23 package DNSTest; 24 24 use strict; 25 25 use warnings; 26 use Exporter; 27 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); 28 @ISA = qw(Exporter); 29 @EXPORT = qw($dnsdb $dbh); 26 30 27 31 use Test::More; … … 32 36 our $dnsdb; 33 37 our $dbh; 38 our $debug; 34 39 35 40 sub new { 41 my $this = shift; 42 my $class = ref($this) || $this; 43 my %args = @_; 44 36 45 $dnsdb = new DNSDB( 37 46 dbhost => 'localhost', … … 43 52 ok( $dnsdb->isa('DNSDB') ); 44 53 54 $debug = 1 if $args{debug}; 55 45 56 ## Prepare the DB 46 57 # Check that we aren't in an obviously production DB before blowing it away. 47 # A DB instantiated for these tests should NEVER have more than a handful of domains and maybe 20-30 records. 48 49 my ($dcount) = $dbh->selectrow_array("SELECT count(*) FROM domains"); 50 BAIL_OUT("# DB looks like it may not be a test DB, found $dcount > 10 domains!\n") 51 if $dcount > 10; 52 cmp_ok( $dcount, '<=', 10, "domain count: looks like a test DB" ); 53 54 my ($rcount) = $dbh->selectrow_array("SELECT count(*) FROM records"); 55 BAIL_OUT("# DB looks like it may not be a test DB, found $rcount > 30 records!\n") 56 if $rcount > 30; 57 cmp_ok( $rcount, '<=', 30, "record count: looks like a test DB" ); 58 # A DB instantiated for these tests should have a known set of domains and records. 58 59 59 60 $dbh = $dnsdb->{dbh}; 60 } 61 62 my ($dcount) = $dbh->selectrow_array("SELECT count(*) FROM domains WHERE NOT domain IN ". 63 "('example.com','example.net','example.org','expiry1.test','expiry2.test')"); 64 BAIL_OUT("# DB looks like it may not be a test DB, found $dcount > 0 non-test domains!\n") 65 if $dcount > 0; 66 cmp_ok( $dcount, '==', 0, "non-test domain count ($dcount): looks like a test DB" ); 67 68 my ($rcount) = $dbh->selectrow_array(qq{SELECT count(*) FROM records WHERE NOT ( 69 host like '%example.com' or host like '%example.net' or host like '%example.org' or 70 host like '%expiry1.test' or host like '%expiry2.test' or inetlazy(val) << '192.168.2.0/27' 71 )}); 72 my $maxrecs = 0; 73 BAIL_OUT("# DB looks like it may not be a test DB, found $rcount > $maxrecs records!\n") 74 if $rcount > $maxrecs; 75 cmp_ok( $rcount, '<=', $maxrecs, "non-test record ($rcount): looks like a test DB" ); 76 77 # drop all tables etc 78 $ENV{PGPASSWORD} = $dnsdb->{dbpass}; 79 # neither diag or note seem to suppress output from qx 80 my $dropdata = qx( psql -h $dnsdb->{dbhost} -U $dnsdb->{dbuser} $dnsdb->{dbname} 2>&1 < t/dropall.sql ); 81 diag( $dropdata ) if $debug; 82 # load some standard test data 83 my $reload = qx( psql -h $dnsdb->{dbhost} -U $dnsdb->{dbuser} $dnsdb->{dbname} 2>&1 < t/dns-unitbase.sql ); 84 diag( $reload ) if $debug; 85 undef $ENV{PGPASSWORD}; 86 } # new() 61 87 62 88 sub DESTROY { -
Property svn:keywords
set to
Note:
See TracChangeset
for help on using the changeset viewer.
![[ DNS Administrator ]](/fx/dnsadmin-logo.png)