removed unnecessary 'file' structure level from Apt packages probe
[scpubgit/System-Introspector.git] / t / packages-apt.t
CommitLineData
8a276d0e 1use strictures 1;
2use Test::More;
f25e8c9f 3use FindBin;
8a276d0e 4
afd7c030 5use System::Introspector::Probe::Packages::Apt;
8a276d0e 6
afd7c030 7my $probe = System::Introspector::Probe::Packages::Apt->new;
8a276d0e 8my $data = $probe->gather;
9
10ok(scalar(keys %$data), 'received packages');
11ok(
1263950b 12 not(grep {
13 not exists $_->{version}
14 } values %{$data->{installed}{packages}}),
8a276d0e 15 'versions',
16);
17
f25e8c9f 18do {
19 local $ENV{PATH} = join ':', "$FindBin::Bin/bin", $ENV{PATH};
5413434d 20 my $source_list = "$FindBin::Bin/data/apt/sources.list";
21 my $source_list_dir = "$FindBin::Bin/data/apt/sources.list.d";
f25e8c9f 22 my $probe = System::Introspector::Probe::Packages::Apt->new(
23 apt_update => 1,
24 apt_update_after => 0,
5413434d 25 apt_sources => $source_list,
26 apt_sources_dir => $source_list_dir,
f25e8c9f 27 );
28 my $data = $probe->gather;
29 is_deeply $data->{upgradable}, {
30 actions => {
31 inst => { foo => '(some foo info)' },
32 remv => { baz => '(some baz info)' },
33 },
34 }, 'upgradable packages';
35 ok $data->{update}{last}, 'has last update time';
36 ok $data->{update}{run}, 'has apt run state';
5413434d 37 is_deeply $data->{sources}, {
38 config => {
39 sources_list => {
1558d0ab 40 file_name => $source_list,
41 body => join "", map "$_\n",
42 "deb http://main.example.com foo",
43 "deb http://main.example.com bar",
5413434d 44 },
45 sources_list_dir => {
46 files => {
47 "other.list" => {
1558d0ab 48 file_name => "$source_list_dir/other.list",
49 body => join "", map "$_\n",
50 "deb http://other.example.com foo",
51 "deb http://other.example.com bar",
5413434d 52 },
53 },
54 }
55 },
56 }, 'sources';
f25e8c9f 57};
58
8a276d0e 59done_testing;