From: Frank Lichtenheld Date: Sun, 13 Jan 2008 15:38:28 +0000 (+0100) Subject: 600_Dpkg_Changelog.t: Add more tests X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aded1d7a4a7c5acfef5f002fb6a3e4f7b0477eed;p=dpkg 600_Dpkg_Changelog.t: Add more tests * scripts/t/600_Dpkg_Changelog.t: Add a new changelog 'fields' that tests the handling of the different fields in the dpkg format. --- diff --git a/ChangeLog b/ChangeLog index 1fb295de..87ba103d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2008-01-13 Frank Lichtenheld + * scripts/t/600_Dpkg_Changelog.t: Add a new changelog + 'fields' that tests the handling of the different fields + in the dpkg format. + * scripts/Dpkg/Changelog.pm: Replace all field hashes with Dpkg::Changelog::Entry objects. (Dpkg::Changelog::Entry): Base on Dpkg::Fields::Object. diff --git a/scripts/Makefile.am b/scripts/Makefile.am index b70a576d..e27f2949 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -72,6 +72,7 @@ EXTRA_DIST = \ t/500_Dpkg_Path.t \ t/600_Dpkg_Changelog.t \ t/600_Dpkg_Changelog/countme \ + t/600_Dpkg_Changelog/fields \ t/600_Dpkg_Changelog/misplaced-tz \ t/600_Dpkg_Changelog/shadow \ t/700_Dpkg_Control.t \ diff --git a/scripts/t/600_Dpkg_Changelog.t b/scripts/t/600_Dpkg_Changelog.t index a9b8f322..6c4837ab 100644 --- a/scripts/t/600_Dpkg_Changelog.t +++ b/scripts/t/600_Dpkg_Changelog.t @@ -6,11 +6,13 @@ use warnings; use File::Basename; BEGIN { - my $no_examples = 2; + my $no_examples = 3; my $no_err_examples = 1; my $no_tests = $no_examples * 4 + $no_err_examples * 2 - + 48; + + 24 # countme + + 2 # fields + + 24; require Test::More; import Test::More tests => $no_tests; @@ -30,7 +32,7 @@ my $test = Dpkg::Changelog::Debian->init( { infile => '/nonexistant', ok( !defined($test), "fatal parse errors lead to init() returning undef"); my $save_data; -foreach my $file ("$srcdir/countme", "$srcdir/shadow") { +foreach my $file ("$srcdir/countme", "$srcdir/shadow", "$srcdir/fields") { my $changes = Dpkg::Changelog::Debian->init( { infile => $file, quiet => 1 } ); @@ -157,6 +159,56 @@ foreach my $file ("$srcdir/countme", "$srcdir/shadow") { 'until => "1:2.0~rc2-1sarge2"' ); #TODO: test combinations } + if ($file eq "$srcdir/fields") { + my $str = $changes->dpkg_str({ all => 1 }); + my $expected = 'Source: fields +Version: 2.0-0etch1 +Distribution: stable +Urgency: high +Maintainer: Frank Lichtenheld +Date: Sun, 13 Jan 2008 15:49:19 +0100 +Closes: 1000000 1111111 1111111 2222222 2222222 +Changes: + fields (2.0-0etch1) stable; urgency=low + . + * Upload to stable (Closes: #1111111, #2222222) + . + fields (2.0-1) unstable; urgency=medium + . + * Upload to unstable (Closes: #1111111, #2222222) + . + fields (2.0~b1-1) unstable; urgency=low,xc-userfield=foobar + . + * Beta + . + fields (1.0) experimental; urgency=high + . + * First upload (Closes: #1000000) +Xc-Userfield: foobar +'; + cmp_ok($str,'eq',$expected,"fields handling"); + + $str = $changes->dpkg_str({ offset => 1, count => 2 }); + $expected = 'Source: fields +Version: 2.0-1 +Distribution: unstable +Urgency: medium +Maintainer: Frank Lichtenheld +Date: Sun, 12 Jan 2008 15:49:19 +0100 +Closes: 1111111 2222222 +Changes: + fields (2.0-1) unstable; urgency=medium + . + * Upload to unstable (Closes: #1111111, #2222222) + . + fields (2.0~b1-1) unstable; urgency=low,xc-userfield=foobar + . + * Beta +Xc-Userfield: foobar +'; + cmp_ok($str,'eq',$expected,"fields handling 2"); + + } # if ($file eq 'Changes') { # my $v = $data[0]->Version; diff --git a/scripts/t/600_Dpkg_Changelog/fields b/scripts/t/600_Dpkg_Changelog/fields new file mode 100644 index 00000000..5f08b713 --- /dev/null +++ b/scripts/t/600_Dpkg_Changelog/fields @@ -0,0 +1,23 @@ +fields (2.0-0etch1) stable; urgency=low + + * Upload to stable (Closes: #1111111, #2222222) + + -- Frank Lichtenheld Sun, 13 Jan 2008 15:49:19 +0100 + +fields (2.0-1) unstable; urgency=medium + + * Upload to unstable (Closes: #1111111, #2222222) + + -- Frank Lichtenheld Sun, 12 Jan 2008 15:49:19 +0100 + +fields (2.0~b1-1) unstable; urgency=low,xc-userfield=foobar + + * Beta + + -- Frank Lichtenheld Sun, 11 Jan 2008 15:49:19 +0100 + +fields (1.0) experimental; urgency=high + + * First upload (Closes: #1000000) + + -- Frank Lichtenheld Sun, 10 Jan 2008 15:49:19 +0100