Commit | Line | Data |
0331d9cd |
1 | use strictures 1; |
2 | use Test::More; |
3 | use FindBin; |
4 | use aliased 'System::Introspector::Report::Source'; |
5 | |
6 | my $source = Source->new(root => "$FindBin::Bin/data/json/"); |
7 | my @reports = $source->generate(['Perls', {}]); |
8 | |
9 | is scalar(@reports), 1, 'single report generated'; |
10 | my $rep = $reports[0]; |
11 | |
12 | is $rep->{id}, 'perls', 'report id'; |
13 | like $rep->{title}, qr{perl}i, 'report title contains perl'; |
14 | is_deeply $rep->{meta}, {}, 'no metadata in this report'; |
15 | is_deeply $rep->{rowid}, [qw( remote location )], 'correct rowid'; |
16 | my %cols = map { ($_->{key}, 1) } @{$rep->{columns}}; |
17 | ok $cols{$_}, "$_ column exists" |
18 | for qw( remote hostname location version ); |
19 | my @rows = ( |
20 | { hostname => 'a.example.com', |
21 | remote => 'hostA', |
22 | location => '/foo/bar/perl', |
23 | version => '5.10.0', |
24 | }, |
25 | { hostname => 'a.example.com', |
26 | remote => 'hostA', |
27 | location => '/foo/baz/perl', |
28 | version => '5.14.1', |
29 | }, |
30 | { hostname => 'b.example.com', |
31 | remote => 'hostB', |
32 | location => '/foo/bar/perl', |
33 | version => '5.10.0', |
34 | }, |
35 | { hostname => 'b.example.com', |
36 | remote => 'hostB', |
37 | location => '/foo/qux/perl', |
38 | version => '5.14.1', |
39 | }, |
40 | ); |
41 | for my $idx (0 .. $#rows) { |
42 | is $rep->{rows}[$idx]{$_}, $rows[$idx]{$_}, "row $idx $_ value" |
43 | for sort keys %{$rows[$idx]}; |
44 | } |
45 | |
46 | done_testing; |