fixed ini file generation from hashref; added default ini file generation; use ini file generation function
--- 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");
--- 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;