81 /], |
81 /], |
82 TXT => 5, |
82 TXT => 5, |
83 AAAA => 0, |
83 AAAA => 0, |
84 MX => 2, |
84 MX => 2, |
85 }, |
85 }, |
|
86 'frey-1' => { |
|
87 RRSETS => 5, |
|
88 SOA => { 'example.com.' => ['p.example.com. hostmaster.example.com. 47 3600 900 604800 300'] }, |
|
89 A => { 'p.example.com.' => ['1.1.1.1'] }, |
|
90 NS => { 'example.com.' => ['p.example.com.'] }, |
|
91 CNAME => { |
|
92 'proxy.mm.frey.example.com.' => ['uxa.frey.example.com.'], |
|
93 'portal.mm.frey.example.com.'=> ['uxb.frey.example.com.'], |
|
94 }, |
|
95 }, |
86 ); |
96 ); |
87 |
97 |
88 # uniq list of rrtypes we want to test |
98 # uniq list of rrtypes we want to test |
89 my @sets = do { |
99 my @sets = do { |
90 my %h; |
100 my %h; |
96 my $file = "t/samples/$sample"; |
106 my $file = "t/samples/$sample"; |
97 |
107 |
98 subtest "sample $file" => sub { |
108 subtest "sample $file" => sub { |
99 my %expect = %{ $expect{$sample} }; |
109 my %expect = %{ $expect{$sample} }; |
100 my @zone = parse(slurp $file); |
110 my @zone = parse(slurp $file); |
101 # diag Dumper \@zone; |
|
102 is @zone, $expect{RRSETS} => "$sample: $expect{RRSETS} RRSETS"; |
111 is @zone, $expect{RRSETS} => "$sample: $expect{RRSETS} RRSETS"; |
103 foreach my $type (@sets) { |
112 foreach my $type (@sets) { |
104 # diag '----------->' . $type; |
|
105 if (ref $expect{$type} eq ref[]) { |
113 if (ref $expect{$type} eq ref[]) { |
106 my @entries = sort map { $_->{label} } grep { $_->{rrtype} eq $type } map { $_->{rrset} } @zone; |
114 my @entries = sort map { $_->{label} } grep { $_->{rrtype} eq $type } map { $_->{rrset} } @zone; |
107 is_deeply \@entries, $expect{$type} => 'list of labels'; |
115 is_deeply \@entries, $expect{$type} => 'list of labels'; |
108 } |
116 } |
109 elsif (ref $expect{$type} eq ref{}) { |
117 elsif (ref $expect{$type} eq ref{}) { |
110 # use Data::Dumper; |
|
111 foreach my $label (keys %{ $expect{$type} }) { |
118 foreach my $label (keys %{ $expect{$type} }) { |
112 #diag Dumper $expect{$type}{$label}; |
|
113 #diag Dumper $expect{$type}; |
|
114 my @entries = sort map { $_->{data} } grep { $_->{label} eq $label and $_->{rrtype} eq $type } map { $_->{rrset} } @zone; |
119 my @entries = sort map { $_->{data} } grep { $_->{label} eq $label and $_->{rrtype} eq $type } map { $_->{rrset} } @zone; |
115 # diag Dumper \@entries; |
|
116 is_deeply \@entries, $expect{$type}{$label} => 'complete rrsets', |
120 is_deeply \@entries, $expect{$type}{$label} => 'complete rrsets', |
117 } |
121 } |
118 } |
122 } |
119 else { |
123 else { |
120 is grep({ $_->{rrset}{rrtype} eq $type } @zone), |
124 is grep({ $_->{rrset}{rrtype} eq $type } @zone), |