Skip to content

Commit 30f8655

Browse files
committed
Fix test t/29warnings.t to use like() instead of parsing regex manually
1 parent 422c377 commit 30f8655

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

t/29warnings.t

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@ use vars qw($test_dsn $test_user $test_password);
1212
my $dbh = DbiTestConnect($test_dsn, $test_user, $test_password,
1313
{ RaiseError => 1, PrintError => 0, AutoCommit => 0 });
1414

15-
my $expected_warnings = 2;
16-
if ($dbh->{mariadb_serverversion} >= 50000 && $dbh->{mariadb_serverversion} < 50500) {
17-
$expected_warnings = 1;
18-
}
19-
2015
plan tests => 14;
2116

2217
ok(defined $dbh, "Connected to database");
@@ -43,15 +38,14 @@ ok($sth->execute());
4338

4439
is($sth->{'mariadb_warning_count'}, 2 );
4540

46-
# $dbh->{mariadb_info} actually uses mysql_info()
47-
my $str = $dbh->{mariadb_info};
48-
my $numwarn;
49-
if ( $str =~ /Warnings:\s(\d+)$/ ) {
50-
$numwarn = $1;
51-
}
52-
5341
# this test passes on mysql 5.5.x and fails on 5.1.x
54-
# but I'm not sure which versions, so I'll just disable it for now
55-
is($numwarn, $expected_warnings);
42+
# so change number of expected warnings from mysql_info()
43+
my $expected_warnings = 2;
44+
if ($dbh->{mariadb_serverversion} >= 50000 && $dbh->{mariadb_serverversion} < 50500) {
45+
$expected_warnings = 1;
46+
}
47+
# $dbh->{mariadb_info} actually uses mysql_info()
48+
my $info = $dbh->{mariadb_info};
49+
like($info, qr/Warnings:\s\Q$expected_warnings\E$/);
5650

5751
ok($dbh->disconnect);

0 commit comments

Comments
 (0)