added header_first to WebPAC::Input::CSV
[webpac2] / t / 2-input-csv.t
index 2ed084e..845d1ee 100755 (executable)
@@ -3,7 +3,7 @@
 use strict;
 use lib 'lib';
 
-use Test::More tests => 63;
+use Test::More tests => 102;
 
 BEGIN {
 use_ok( 'WebPAC::Test' );
@@ -39,3 +39,20 @@ foreach my $mfn ( 1 ... $size ) {
        diag "rec: ", dump($rec), "\n" if $debug;
 }
 
+ok(my $db = $input->open(
+       path => "$abs_path/data/header_first.csv",
+       header_first => 1,
+), "open");
+ok(my $size = $input->size, "size");
+cmp_ok( $size, '==', 10 - 1, 'size header_first' );
+
+foreach my $mfn ( 1 ... $size ) {
+       my $rec = $input->fetch;
+       ok($rec, "fetch $mfn");
+       cmp_ok($rec->{'000'}->[0], '==', $mfn, 'has mfn');
+       cmp_ok($input->pos, '==', $mfn, "pos $mfn");
+
+       cmp_ok( $rec->{'A'}, 'eq', $rec->{'publication_title'}, 'A eq publication_title' );
+       diag "rec: ", dump($rec), "\n" if $debug;
+}
+