452c8e36d1
The NrBuilds table tracks the value of ‘select count(*) from Builds where finished = 0’, keeping it up to date via a trigger. This is necessary to make the /all page fast, since otherwise it needs to do a sequential scan on the Builds table.
22 lines
645 B
Perl
Executable file
22 lines
645 B
Perl
Executable file
use strict;
|
|
use Hydra::Schema;
|
|
use Hydra::Model::DB;
|
|
|
|
my $db = Hydra::Model::DB->new;
|
|
|
|
my @sources = $db->schema->sources;
|
|
my $nrtables = scalar(@sources);
|
|
|
|
use Test::Simple tests => 44;
|
|
|
|
foreach my $source (@sources) {
|
|
my $title = "Basic select query for $source";
|
|
if ($source eq "SchemaVersion" || $source eq "NrBuilds") {
|
|
ok(scalar($db->resultset($source)->all) == 1, $title);
|
|
} elsif( $source !~ m/^(LatestSucceeded|JobStatus|ActiveJobs)/) {
|
|
ok(scalar($db->resultset($source)->all) == 0, $title);
|
|
} else {
|
|
ok(scalar($db->resultset($source)->search({},{ bind => ["", "", ""] })) == 0, $title);
|
|
}
|
|
}
|