t/00-config.t
branchhs12
changeset 80 fc2156761c29
child 85 c47953192c5c
equal deleted inserted replaced
79:ac04894f45c1 80:fc2156761c29
       
     1 #! /usr/bin/perl
       
     2 
       
     3 use strict;
       
     4 use warnings;
       
     5 use Test::More;
       
     6 use Pod::Coverage;
       
     7 use File::Temp;
       
     8 
       
     9 BEGIN {
       
    10     use_ok "DNStools::Config", "get_config";
       
    11 }
       
    12 
       
    13 can_ok("DNStools::Config" => "get_config");
       
    14 
       
    15 # should die if there is no config
       
    16 eval { get_config() };
       
    17 ok($@, "dies on missing file names");
       
    18 
       
    19 eval { get_config("xxx|xxx", "yyy|yyy") };
       
    20 ok($@, "dies on missing config");
       
    21 
       
    22 # prepare some simple sample config
       
    23 my $tmp = File::Temp->new();
       
    24 print {$tmp} <<__EOF;
       
    25 # comment
       
    26 abc = xyz
       
    27 other =    value with space
       
    28 __EOF
       
    29 close($tmp);
       
    30 
       
    31 my %cf = get_config($tmp->filename);
       
    32 ok(%cf, "got config");
       
    33 
       
    34 is($cf{abc} => "xyz", "simple value");
       
    35 is($cf{other} => "valuewithspace", "spaced value");
       
    36 
       
    37 
       
    38 done_testing();