Skip to content

Commit c77971f

Browse files
committed
add perl_version relationship to stats rows
This allows us to filter stats rows based on Perl maturity
1 parent 8c53bbf commit c77971f

File tree

2 files changed

+45
-9
lines changed

2 files changed

+45
-9
lines changed

lib/CPAN/Testers/Schema/Result/Stats.pm

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,4 +271,14 @@ Get the related row in the `uploads` table. See L<CPAN::Testers::Schema::Result:
271271

272272
belongs_to upload => 'CPAN::Testers::Schema::Result::Upload' => 'uploadid';
273273

274+
=method perl_version
275+
276+
Get the related metadata about the Perl version this report is for. See
277+
L<CPAN::Testers::Schema::Result::PerlVersion>.
278+
279+
=cut
280+
281+
might_have perl_version => 'CPAN::Testers::Schema::Result::PerlVersion' =>
282+
{ 'foreign.version' => 'self.perl' };
283+
274284
1;

t/result/stats.t

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,42 @@ L<CPAN::Testers::Schema>, L<DBIx::Class>
1111

1212
use CPAN::Testers::Schema::Base 'Test';
1313

14+
my $schema = prepare_temp_schema;
15+
my %upload = (
16+
type => 'cpan',
17+
dist => 'My-Dist',
18+
version => '1.000',
19+
author => 'PREACTION',
20+
filename => 'My-Dist-1.000.tar.gz',
21+
released => 1366237867,
22+
);
23+
my $upload = $schema->resultset( 'Upload' )->create( \%upload );
24+
1425
subtest 'upload relationship' => sub {
15-
my $schema = prepare_temp_schema;
16-
my %upload = (
17-
type => 'cpan',
26+
my %stats = (
27+
type => 2,
28+
guid => '00000000-0000-0000-0000-000000000000',
29+
state => 'pass',
30+
postdate => '201607',
31+
tester => '[email protected] (Doug Bell)',
1832
dist => 'My-Dist',
1933
version => '1.000',
20-
author => 'PREACTION',
21-
filename => 'My-Dist-1.000.tar.gz',
22-
released => 1366237867,
34+
platform => 'darwin-2level',
35+
perl => '5.24.0',
36+
osname => 'darwin',
37+
osvers => '15.5.0',
38+
fulldate => '201607141234',
39+
uploadid => $upload->uploadid,
2340
);
24-
my $upload = $schema->resultset( 'Upload' )->create( \%upload );
41+
my $stats = $schema->resultset( 'Stats' )->create( \%stats );
42+
43+
ok $stats->upload, 'upload relationship exists';
44+
is $stats->upload->uploadid, $upload->uploadid, 'correct upload is related';
45+
};
46+
47+
subtest 'perl_version relationship' => sub {
48+
my $schema = prepare_temp_schema;
49+
my $version_row = $schema->resultset( 'PerlVersion' )->create({ version => '5.24.0' });
2550

2651
my %stats = (
2752
type => 2,
@@ -40,8 +65,9 @@ subtest 'upload relationship' => sub {
4065
);
4166
my $stats = $schema->resultset( 'Stats' )->create( \%stats );
4267

43-
ok $stats->upload, 'upload relationship exists';
44-
is $stats->upload->uploadid, $upload->uploadid, 'correct upload is related';
68+
ok $stats->perl_version, 'perl_version relationship exists';
69+
is $stats->perl_version->perl, '5.24.0', 'correct perl version is related';
70+
4571
};
4672

4773
done_testing;

0 commit comments

Comments
 (0)