diff -r 7c94598b7649 -r c47953192c5c t/00-config.t --- a/t/00-config.t Sun Jan 16 17:28:48 2011 +0100 +++ b/t/00-config.t Sun Jan 16 17:29:01 2011 +0100 @@ -12,15 +12,13 @@ can_ok("DNStools::Config" => "get_config"); -# should die if there is no config -eval { get_config() }; -ok($@, "dies on missing file names"); - eval { get_config("xxx|xxx", "yyy|yyy") }; ok($@, "dies on missing config"); +my ($tmp, %cf); + # prepare some simple sample config -my $tmp = File::Temp->new(); +$tmp = File::Temp->new(); print {$tmp} <<__EOF; # comment abc = xyz @@ -28,9 +26,18 @@ __EOF close($tmp); -my %cf = get_config($tmp->filename); +# the files is specified, it should find the first +# existing +%cf = get_config("xxx|xxx", $tmp->filename); ok(%cf, "got config"); +is($cf{abc} => "xyz", "simple value"); +is($cf{other} => "valuewithspace", "spaced value"); +# it should find the file specified in $ENV{DNSTOOLS_CONF} +$ENV{DNSTOOLS_CONF} = $tmp->filename; +%cf = (); +%cf = get_config("xxx|xxx", $tmp->filename); +ok(%cf, "got config from env"); is($cf{abc} => "xyz", "simple value"); is($cf{other} => "valuewithspace", "spaced value");