File: Catmandu-Fix-lookup_in_store.t

package info (click to toggle)
libcatmandu-perl 1.0304-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 2,756 kB
  • ctags: 695
  • sloc: perl: 13,756; makefile: 34
file content (40 lines) | stat: -rw-r--r-- 1,003 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env perl

use strict;
use warnings;
use Test::More;
use Test::Exception;

use Data::Dumper;

my $pkg;

BEGIN {
    $pkg = 'Catmandu::Fix::lookup_in_store';
    use_ok $pkg;
}

require_ok $pkg;

is_deeply $pkg->new('planet', 'test')->fix({planet => 'Earth'}),
    {planet => {_id => 'Earth', value => 'Terra'}};

is_deeply $pkg->new('planet', 'test')->fix({planet => 'Bartledan'}),
    {planet => 'Bartledan'};

is_deeply $pkg->new('planet', 'test', 'delete', 1)
    ->fix({planet => 'Bartledan'}), {};

is_deeply $pkg->new('planets.*', 'test', 'delete', 1)
    ->fix({planets => ['Bartledan', 'Earth']}),
    {planets => [{_id => 'Earth', value => 'Terra'}]};

is_deeply $pkg->new('planet', 'test', 'default', 'Mars')
    ->fix({planet => 'Bartledan'}), {planet => 'Mars'};

is_deeply $pkg->new('planets.*', 'test', 'default', 'Mars')
    ->fix({planets => ['Bartledan', 'Earth']}),
    {planets => ['Mars', {_id => 'Earth', value => 'Terra'}]},
    'default with wildcard';

done_testing 8;