simplified ResolvConf probe output and make it conform to standard file data structure
[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 => {
40 file => {
41 file_name => $source_list,
42 body => join "", map "$_\n",
43 "deb http://main.example.com foo",
44 "deb http://main.example.com bar",
45 },
46 },
47 sources_list_dir => {
48 files => {
49 "other.list" => {
50 file => {
51 file_name => "$source_list_dir/other.list",
52 body => join "", map "$_\n",
53 "deb http://other.example.com foo",
54 "deb http://other.example.com bar",
55 },
56 },
57 },
58 }
59 },
60 }, 'sources';
f25e8c9f 61};
62
8a276d0e 63done_testing;