better view membership test
authorJason Etheridge <jason@esilibrary.com>
Wed, 24 Jul 2013 20:14:43 +0000 (16:14 -0400)
committerJason Etheridge <jason@esilibrary.com>
Wed, 24 Jul 2013 20:14:43 +0000 (16:14 -0400)
Signed-off-by: Jason Etheridge <jason@esilibrary.com>
Open-ILS/src/sql/Pg/make-pgtap-tests.pl

index cd1ef86..a6ec784 100755 (executable)
@@ -217,12 +217,22 @@ sub handle_views {
     my $callback = shift;
 
     my @views = fetch_views($schema);
+    if (scalar @views == 0) {
+        return;
+    }
+
+    print "SELECT views_are(\n";
+    print "\t" . $dbh->quote($schema) . ",\n";
+    print "\tARRAY[\n\t\t";
+    print join(
+        ",\n\t\t",
+        map { $dbh->quote($_) } @views
+    );
+    print "\n\t],\t" . $dbh->quote("Found expected views for schema $schema");
+    print "\n);\n";
+
     foreach my $view ( @views ) {
         print "\n-- -- view " . $dbh->quote("$schema.$view") . "\n\n";
-        print "SELECT has_view(\n";
-        print "\t" . $dbh->quote($schema) . ",\n";
-        print "\t" . $dbh->quote($view) . ",\n";
-        print "\t" . $dbh->quote("Has view $schema.$view") . "\n);\n";
         $callback->($schema,$view) if $callback;
     }
 }