format: fix render_bytes with CLIFormatter
[pve-common.git] / test / format_test.pl
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use lib '../src';
7 use PVE::JSONSchema;
8
9 use Test::More;
10 use Test::MockModule;
11
12 my $valid_configids = [
13 'aa', 'a0', 'a_', 'a-', 'a-a', 'a'x100, 'Aa', 'AA',
14 ];
15 my $invalid_configids = [
16 'a', 'a+', '1a', '_a', '-a', '+a', 'A',
17 ];
18
19 my $noerr = 1; # easier to test
20 foreach my $id (@$valid_configids) {
21 is(PVE::JSONSchema::pve_verify_configid($id, $noerr), $id, 'valid configid');
22 }
23 foreach my $id (@$invalid_configids) {
24 is(PVE::JSONSchema::pve_verify_configid($id, $noerr), undef, 'invalid configid');
25 }
26
27 done_testing();