summaryrefslogtreecommitdiff
path: root/scripts/t/Dpkg_Dist_Files.t
diff options
context:
space:
mode:
authorGuillem Jover <guillem@debian.org>2014-01-28 01:08:01 +0100
committerGuillem Jover <guillem@debian.org>2014-04-21 16:29:44 +0200
commitbe7da07bbc26cf9b799fa6425b60025ab0e91956 (patch)
treedab6aef4dcd3b1272e53ce8b53ad4b1fd2963e20 /scripts/t/Dpkg_Dist_Files.t
parent1469ab6fc964ffd7f83e4e842ad4cf89a48328e5 (diff)
downloaddpkg-be7da07bbc26cf9b799fa6425b60025ab0e91956.tar.gz
Dpkg::Dist::Files: New perl module
Diffstat (limited to 'scripts/t/Dpkg_Dist_Files.t')
-rw-r--r--scripts/t/Dpkg_Dist_Files.t95
1 files changed, 95 insertions, 0 deletions
diff --git a/scripts/t/Dpkg_Dist_Files.t b/scripts/t/Dpkg_Dist_Files.t
new file mode 100644
index 000000000..6ec05f9ce
--- /dev/null
+++ b/scripts/t/Dpkg_Dist_Files.t
@@ -0,0 +1,95 @@
+#!/usr/bin/perl
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+use strict;
+use warnings;
+
+use Test::More tests => 8;
+
+use_ok('Dpkg::Dist::Files');
+
+my $srcdir = $ENV{srcdir} // '.';
+my $datadir = $srcdir . '/t/Dpkg_Dist_Files';
+
+my $expected;
+my %expected = (
+ 'pkg-templ_1.2.3_arch.type' => {
+ filename => 'pkg-templ_1.2.3_arch.type',
+ package => 'pkg-templ',
+ package_type => 'type',
+ version => '1.2.3',
+ arch => 'arch',
+ section => 'section',
+ priority => 'priority',
+ },
+ 'pkg-arch_2.0.0_amd64.deb' => {
+ filename => 'pkg-arch_2.0.0_amd64.deb',
+ package => 'pkg-arch',
+ package_type => 'deb',
+ version => '2.0.0',
+ arch => 'amd64',
+ section => 'admin',
+ priority => 'required',
+ },
+ 'pkg-indep_0.0.1-2_all.deb' => {
+ filename => 'pkg-indep_0.0.1-2_all.deb',
+ package => 'pkg-indep',
+ package_type => 'deb',
+ version => '0.0.1-2',
+ arch => 'all',
+ section => 'net',
+ priority => 'standard',
+ },
+ 'other_0.txt' => {
+ filename => 'other_0.txt',
+ section => 'text',
+ priority => 'optional',
+ },
+ 'BY-HAND-file' => {
+ filename => 'BY-HAND-file',
+ section => 'webdocs',
+ priority => 'optional',
+ },
+);
+
+my $dist = Dpkg::Dist::Files->new();
+$dist->load("$datadir/files-byhand") or error('cannot parse file');
+
+$expected = 'pkg-templ_1.2.3_arch.type section priority
+pkg-arch_2.0.0_amd64.deb admin required
+pkg-indep_0.0.1-2_all.deb net standard
+other_0.txt text optional
+BY-HAND-file webdocs optional
+';
+
+is($dist->output(), $expected, 'Parsed dist file');
+foreach my $f ($dist->get_files()) {
+ is_deeply($f, $expected{$f->{filename}},
+ "Detail for individual dist file $f->{filename}");
+}
+
+$expected = 'pkg-templ_1.2.3_arch.type section priority
+pkg-arch_2.0.0_amd64.deb void imperative
+other_0.txt text optional
+BY-HAND-file webdocs optional
+added-on-the-fly void wish
+';
+
+$dist->add_file('added-on-the-fly', 'void', 'wish');
+$dist->add_file('pkg-arch_2.0.0_amd64.deb', 'void', 'imperative');
+$dist->del_file('pkg-indep_0.0.1-2_all.deb');
+is($dist->output(), $expected, 'Modified dist object');
+
+1;