File: Catmandu-Store-File-FedoraCommons-Index.t

package info (click to toggle)
libcatmandu-fedoracommons-perl 0.5-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 568 kB
  • sloc: perl: 2,523; xml: 78; makefile: 7
file content (66 lines) | stat: -rw-r--r-- 1,318 bytes parent folder | download
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
use strict;
use warnings;
use Test::More;
use Test::Exception;
use Catmandu::Store::File::FedoraCommons;

my $host = $ENV{FEDORA_HOST} || "";
my $port = $ENV{FEDORA_PORT} || "";
my $user = $ENV{FEDORA_USER} || "";
my $pwd  = $ENV{FEDORA_PWD}  || "";

my $pkg;

BEGIN {
    $pkg = 'Catmandu::Store::File::FedoraCommons::Index';
    use_ok $pkg;
}
require_ok $pkg;

SKIP: {
    skip "No Fedora server environment settings found (FEDORA_HOST,"
	 . "FEDORA_PORT,FEDORA_USER,FEDORA_PWD).",
	100 if (! $host || ! $port || ! $user || ! $pwd);

    my $store
        = Catmandu::Store::File::FedoraCommons->new(purge => 1);

    ok $store , 'got a store';

    my $index;

    note("index");
    {
        $index = $store->bag();

        ok $index , 'got the index bag';
    }

    note("list");
    {
        my $array = $index->to_array;

        ok $array , 'list got a response';

        ok grep({ $_->{_id} eq 'SmileyWastebasket' } @$array), 'got a SmileyWastebasket';
    }

    note("get");
    {
        for (qw(SmileyToiletBrush SmileyTallRoundCup SmileyWastebasket)) {
            ok $index->get($_), "get($_)";
        }
    }

    note("add");
    {
        ok $index->add({_id => '1234'}) , 'add(1234)';
    }

    note("delete");
    {
        ok $index->delete('1234'), 'delete(1234)';
    }
}

done_testing;