diff -r 53c95f2ff0ac -r 0e1e5027e9c0 t/00-config.t --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/t/00-config.t Sun Jan 23 00:30:15 2011 +0100 @@ -0,0 +1,45 @@ +#! /usr/bin/perl + +use strict; +use warnings; +use Test::More; +use Pod::Coverage; +use File::Temp; + +BEGIN { + use_ok "DNStools::Config" => qw(get_config); +} + +can_ok("DNStools::Config" => "get_config"); + +eval { get_config("xxx|xxx", "yyy|yyy") }; +ok($@, "dies on missing config"); + +my ($tmp, %cf); + +# prepare some simple sample config +$tmp = File::Temp->new(); +print {$tmp} <<__EOF; +# comment +abc = xyz +other = value with space +__EOF +close($tmp); + +# 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 \$DNSTOOLS_CONF"); +is($cf{abc} => "xyz", "simple value"); +is($cf{other} => "valuewithspace", "spaced value"); + + +done_testing();