Просмотр исходного кода

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.
Frank Lichtenheld лет назад: 18
Родитель
Сommit
aded1d7a4a
4 измененных файлов с 83 добавлено и 3 удалено
  1. 4 0
      ChangeLog
  2. 1 0
      scripts/Makefile.am
  3. 55 3
      scripts/t/600_Dpkg_Changelog.t
  4. 23 0
      scripts/t/600_Dpkg_Changelog/fields

+ 4 - 0
ChangeLog

@@ -1,5 +1,9 @@
 2008-01-13  Frank Lichtenheld  <djpig@debian.org>
 
+	* 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.

+ 1 - 0
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 \

+ 55 - 3
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 <frank@lichtenheld.de>
+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 <djpig@debian.org>
+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;

+ 23 - 0
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 <frank@lichtenheld.de>  Sun, 13 Jan 2008 15:49:19 +0100
+
+fields (2.0-1) unstable; urgency=medium
+
+  * Upload to unstable (Closes: #1111111, #2222222)
+
+ -- Frank Lichtenheld <djpig@debian.org>  Sun, 12 Jan 2008 15:49:19 +0100
+
+fields (2.0~b1-1) unstable; urgency=low,xc-userfield=foobar
+
+  * Beta
+
+ -- Frank Lichtenheld <frank@lichtenheld.de>  Sun, 11 Jan 2008 15:49:19 +0100
+
+fields (1.0) experimental; urgency=high
+
+  * First upload (Closes: #1000000)
+
+ -- Frank Lichtenheld <djpig@debian.org>  Sun, 10 Jan 2008 15:49:19 +0100