apt source loading and tests for Packages::Apt probe
[scpubgit/System-Introspector.git] / t / packages-apt.t
index 63b8b67..74aa7d6 100644 (file)
@@ -17,9 +17,13 @@ ok(
 
 do {
     local $ENV{PATH} = join ':', "$FindBin::Bin/bin", $ENV{PATH};
+    my $source_list = "$FindBin::Bin/data/apt/sources.list";
+    my $source_list_dir = "$FindBin::Bin/data/apt/sources.list.d";
     my $probe = System::Introspector::Probe::Packages::Apt->new(
         apt_update => 1,
         apt_update_after => 0,
+        apt_sources => $source_list,
+        apt_sources_dir => $source_list_dir,
     );
     my $data = $probe->gather;
     is_deeply $data->{upgradable}, {
@@ -30,6 +34,30 @@ do {
     }, 'upgradable packages';
     ok $data->{update}{last}, 'has last update time';
     ok $data->{update}{run}, 'has apt run state';
+    is_deeply $data->{sources}, {
+        config => {
+            sources_list => {
+                file => {
+                    file_name => $source_list,
+                    body => join "", map "$_\n",
+                        "deb http://main.example.com foo",
+                        "deb http://main.example.com bar",
+                },
+            },
+            sources_list_dir => {
+                files => {
+                    "other.list" => {
+                        file => {
+                            file_name => "$source_list_dir/other.list",
+                            body => join "", map "$_\n",
+                                "deb http://other.example.com foo",
+                                "deb http://other.example.com bar",
+                        },
+                    },
+                },
+            }
+        },
+    }, 'sources';
 };
 
 done_testing;