[libcatmandu-marc-perl] 44/208: Adding test

Jonas Smedegaard dr at jones.dk
Sat Oct 28 03:42:33 UTC 2017


This is an automated email from the git hooks/post-receive script.

js pushed a commit to annotated tag upstream/1.19
in repository libcatmandu-marc-perl.

commit 0cdd7605c095146426d5d93a3c6d570fdaa9c44c
Author: Patrick Hochstenbach <patrick.hochstenbach at ugent.be>
Date:   Mon Sep 12 11:55:38 2016 +0200

    Adding test
---
 t/20-marc_has.t | 45 +++++++++++++++++++++++++++++++++++++++++++++
 t/rug01.aleph   |  2 +-
 2 files changed, 46 insertions(+), 1 deletion(-)

diff --git a/t/20-marc_has.t b/t/20-marc_has.t
new file mode 100644
index 0000000..a3416c5
--- /dev/null
+++ b/t/20-marc_has.t
@@ -0,0 +1,45 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use warnings qw(FATAL utf8);
+use utf8;
+
+use Test::More;
+
+use Catmandu::Importer::MARC;
+use Catmandu::Fix;
+
+
+my $fixes = <<EOF;
+if marc_has(245)
+  add_field(test.\$append,'has 245')
+end
+
+if marc_has_many(CAT)
+  add_field(test.\$append,'has many CAT')
+end
+
+if marc_has_many(920a)
+  add_field(test.\$append,'has many 920a')
+end
+
+unless marc_has_many(100a)
+  add_field(test.\$append,'has not more than one 100a')
+end
+EOF
+
+my $fixer = Catmandu::Fix->new(fixes => [$fixes]);
+my $importer = Catmandu::Importer::MARC->new( file => 't/rug01.aleph', type => "ALEPHSEQ" );
+my $records = $fixer->fix($importer)->to_array;
+
+my $errors = $records->[0]->{test};
+
+is_deeply $errors , [
+        'has 245' ,
+        'has many CAT' ,
+        'has many 920a' ,
+        'has not more than one 100a' ,
+];
+
+done_testing;
diff --git a/t/rug01.aleph b/t/rug01.aleph
index 9df1337..db62bce 100644
--- a/t/rug01.aleph
+++ b/t/rug01.aleph
@@ -21,7 +21,7 @@
 000000002 650 0 L $$aSpeech acts (Linguistics)
 000000002 650 0 L $$aGenerative grammar.
 000000002 650 0 L $$aCompetence and performance (Linguistics)
-000000002 920   L $$abook
+000000002 920   L $$abook$$abla
 000000002 SID   L $$aZ39$$bLOC
 000000002 CAT   L $$a$$b00$$c19970601$$lRUG01$$h0958
 000000002 CAT   L $$a$$b00$$c19961224$$lRUG01$$h1724

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libcatmandu-marc-perl.git



More information about the Pkg-perl-cvs-commits mailing list