source: branches/UKMO/r6232_tracer_advection/NEMOGCM/EXTERNAL/fcm/t/Fcm/Keyword/Loader/Config/Location.t @ 9295

Last change on this file since 9295 was 9295, checked in by jcastill, 3 years ago

Remove svn keywords

File size: 1.8 KB
Line 
1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6use Fcm::Config;
7use Fcm::Keyword::Entries;
8use Test::More qw{no_plan};
9
10my %VALUE_OF = (
11    foo => 'fcm-test://foo/foo',
12    bar => 'fcm-test://bar/bar',
13    baz => 'fcm-test://baz/baz',
14);
15
16main();
17
18sub main {
19    my $class = 'Fcm::Keyword::Loader::Config::Location';
20    use_ok($class);
21    test_constructor($class);
22    test_load_to($class);
23}
24
25################################################################################
26# Tests simple usage of the constructor
27sub test_constructor {
28    my ($class) = @_;
29    my $prefix = "constructor";
30    my $loader = $class->new();
31    isa_ok($loader, $class);
32    is($loader->get_source(), 'Fcm::Config', "$prefix: get_source()");
33}
34
35################################################################################
36# Tests loading to an Fcm::Keyword::Entries object
37sub test_load_to {
38    my ($class) = @_;
39    my $prefix = 'load to';
40    my $config = Fcm::Config->instance();
41    for my $key (keys(%VALUE_OF)) {
42        $config->setting(['URL', $key], $VALUE_OF{$key});
43    }
44    my $loader = $class->new();
45    my $entries = Fcm::Keyword::Entries->new({
46        entry_class => 'Fcm::Keyword::Entry::Location',
47    });
48    isnt($loader->load_to($entries), 0, "$prefix: number loaded");
49    for my $key (keys(%VALUE_OF)) {
50        my $entry = $entries->get_entry_by_key($key);
51        if ($entry) {
52            is($entry->get_key(), uc($key), "$prefix: by key: $key");
53            is($entry->get_value(), $VALUE_OF{$key}, "$prefix: by value: $key");
54            is(
55                $entries->get_entry_by_value($VALUE_OF{$key}),
56                $entry,
57                "$prefix: by key: $key: object",
58            );
59        }
60        else {
61            fail("$prefix: by key: $key");
62        }
63    }
64}
65
66# TODO: tests loading of browser mapping
67
68__END__
Note: See TracBrowser for help on using the repository browser.