| 1 |
#!perl |
| 2 |
|
| 3 |
use strict; |
| 4 |
use warnings; |
| 5 |
use Test::More; |
| 6 |
use Test::Exception; |
| 7 |
use Catmandu::Exporter::MARC; |
| 8 |
use JSON::XS; |
| 9 |
|
| 10 |
my $pkg; |
| 11 |
|
| 12 |
BEGIN { |
| 13 |
$pkg = 'Catmandu::Exporter::MARC::MiJ'; |
| 14 |
use_ok $pkg; |
| 15 |
} |
| 16 |
|
| 17 |
require_ok $pkg; |
| 18 |
|
| 19 |
my $json = undef; |
| 20 |
|
| 21 |
my $exporter = Catmandu::Exporter::MARC->new(file => \$json, type=> 'MiJ' , skip_empty_subfields => 1); |
| 22 |
|
| 23 |
ok $exporter , 'got an MARC/MiJ exporter'; |
| 24 |
|
| 25 |
ok $exporter->add({ |
| 26 |
_id => '1' , |
| 27 |
record => [ |
| 28 |
['001', undef, undef, '_', 'rec001'], |
| 29 |
['100', ' ', ' ', 'a', 'Davis, Miles' , 'c' , 'Test'], |
| 30 |
['245', ' ', ' ', |
| 31 |
'a', 'Sketches in Blue' , |
| 32 |
], |
| 33 |
['500', ' ', ' ', 'a', "test"], |
| 34 |
['501', ' ', ' ', 'a', "test"], |
| 35 |
['502', ' ', ' ', 'a', "bla", 'b' , 'ok'], |
| 36 |
] |
| 37 |
}) , 'add a record'; |
| 38 |
|
| 39 |
ok $exporter->commit , 'commit'; |
| 40 |
|
| 41 |
my $perl = decode_json $json; |
| 42 |
|
| 43 |
ok $perl , 'decode json'; |
| 44 |
|
| 45 |
done_testing; |