From cec7e7d0527f976985ac4e36eb1f6708f330dc0c Mon Sep 17 00:00:00 2001 From: Carlos Salguero Date: Fri, 30 Mar 2018 19:31:32 -0300 Subject: [PATCH] PT-1488 Added a test --- t/pt-show-grants/mysql_8_roles.t | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/t/pt-show-grants/mysql_8_roles.t b/t/pt-show-grants/mysql_8_roles.t index 5f787628..5bb25e59 100644 --- a/t/pt-show-grants/mysql_8_roles.t +++ b/t/pt-show-grants/mysql_8_roles.t @@ -25,7 +25,7 @@ if ( !$dbh ) { } elsif ($sandbox_version < '8.0') { plan skip_all => "There are no roles in this MySQL version. Need MySQL 8.0+"; } else { - plan tests => 4; + plan tests => 49; } $sb->wipe_clean($dbh); @@ -77,6 +77,26 @@ unlike( ); +## Do a cleanup and try to run all the queries from the output +for my $query(@$cleanup_queries) { + $sb->do_as_root('master', $query); +} + +my @lines = split(/\n/, $output); +my $count=0; + +for my $query(@lines) { + next if $query =~ m/^-- /; + $count++; + eval { $sb->do_as_root('master', $query) }; + is( + $EVAL_ERROR, + '', + "Ran query $count from the output of pt-show grants", + ) or diag("Cannot execute query from the output: $query -> $EVAL_ERROR"); +} + +## Cleanup to leave sandbox ready for next test file. for my $query(@$cleanup_queries) { $sb->do_as_root('master', $query); }