]>
git.proxmox.com Git - pve-common.git/blob - test/section_config_test.pl
11 use base
qw(PVE::SectionConfig);
15 type
=> { description
=> "Section type." },
19 format
=> 'pve-configid',
24 description
=> 'common value',
35 my ($class, $filename, $expected, $raw, $allow_unknown) = @_;
37 my $res = $class->parse_config($filename, $raw, $allow_unknown);
38 delete $res->{digest
};
40 is_deeply
($res, $expected, $filename);
42 my $written = $class->write_config($filename, $res, $allow_unknown);
43 my $res2 = $class->parse_config($filename, $written, $allow_unknown);
44 delete $res2->{digest
};
46 is_deeply
($res, $res2, "$filename - verify rewritten data");
50 my ($class, $filename, $expected, $raw) = @_;
52 eval { $class->parse_config($filename, $raw) };
53 die "test '$filename' succeeded unexpectedly\n" if !$@;
54 ok
(1, "$filename should fail to parse");
70 description
=> 'Field One',
76 description
=> 'Another field',
84 common
=> { optional
=> 1 },
86 another
=> { optional
=> 1 },
103 description
=> 'Field Two',
113 common
=> { optional
=> 1 },
126 Conf
::One-
>register();
127 Conf
::Two-
>register();
130 # FIXME: allow development debug warnings?!
131 local $SIG{__WARN__
} = sub { die @_; };
135 return { map { $_ => $n++ } @_ };
138 Conf-
>expect_success(
151 another
=> 'more-text',
156 another
=> 'even more text',
159 order
=> { t1
=> 1, t2
=> 2, t3
=> 3 },
173 another even more text
176 my $with_unknown_data = {
187 another
=> 'more-text',
192 another
=> 'even more text',
199 order
=> enum
(qw(t1 t2 invalid t3)),
201 my $with_unknown_text = <<"EOF";
216 another even more text
219 Conf-
>expect_fail('unknown-forbidden', $with_unknown_data, $with_unknown_text);
220 Conf-
>expect_success('unknown-allowed', $with_unknown_data, $with_unknown_text, 1);