# HG changeset patch # User Matthias Förste # Date 1309419938 -7200 # Node ID be90bcd14ae1b5eaa666da66125371dc570239b4 # Parent c26b5fa3f646d2b2c750eab2e5e1926d12416e53 fixed ini file generation from hashref; added default ini file generation; use ini file generation function diff -r c26b5fa3f646 -r be90bcd14ae1 t/01-zone-mk.t --- a/t/01-zone-mk.t Wed Jun 29 11:42:51 2011 +0200 +++ b/t/01-zone-mk.t Thu Jun 30 09:45:38 2011 +0200 @@ -1,6 +1,9 @@ use strict; use warnings; +use lib 't/lib'; +use Aux; + use Test::More; use File::Temp qw(tempdir); use Net::LibIDN qw(:all); @@ -22,18 +25,15 @@ system("$CMD &>/dev/null"); ok($? > 0, "error on missing args"); -my $master_dir = tempdir CLEANUP => 1; -my $config_dir = tempdir CLEANUP => 1; -my $tmp = File::Temp->new; + +$_ = File::Temp::tempdir CLEANUP => 1 or die "Can't make temporary directory" for my ($master_dir, $config_dir); +my $tmp = Aux::make_config { + master_dir => $master_dir, + zone_conf_dir => $config_dir, + hostmaster => 'hostmaster@schlittermann.de', + template_dir => './templates' +}; $ENV{DNSTOOLS_CONF} = $tmp->filename; - -print $tmp <<__EOF; -master_dir = $master_dir -zone_conf_dir = $config_dir -hostmaster = hostmaster\@schlittermann.de -template_dir = ./templates -__EOF - system("$CMD xxx müller.de &>/dev/null"); is($? => 0, "created zone"); diff -r c26b5fa3f646 -r be90bcd14ae1 t/lib/Aux.pm --- a/t/lib/Aux.pm Wed Jun 29 11:42:51 2011 +0200 +++ b/t/lib/Aux.pm Thu Jun 30 09:45:38 2011 +0200 @@ -16,10 +16,35 @@ my $f = File::Temp->new or die "Config file creation failed\n"; if (ref $c eq 'HASH') { - map { print $f "$_ = $c->$_\n" } keys %{$c}; - } else { + map { print $f "$_ = $c->{$_}\n" } keys %{$c}; + } elsif (defined $c) { # assuming just a string print $f $c; + } else { + # make a default configuration + my ($bd, $md, $cd); + for ($bd, $md, $cd) { + my $d = File::Temp::tempdir CLEANUP => 1 or die "Can't make temporary directory"; + $_ = $d->filename; + } + + print $f <<__EOF; +bind_dir = $bd +master_dir = $md +zone_conf_dir = $cd + +key_counter_end = 15 +sign_alert_time = 168 +abl_zeit = 24 + +secondary = hh.schlittermann.de +primary = pu.schlittermann.de +hostmaster = hostmaster\@schlittermann.de + +indexzone = idx.tld +template_dir = ./templates +__EOF + } return $f;