mirror of
git://git.proxmox.com/git/pve-common.git
synced 2024-12-22 21:33:47 +03:00
Add tests for verify_configid
Signed-off-by: Dominic Jäger <d.jaeger@proxmox.com>
This commit is contained in:
parent
a7886364a7
commit
e37d592413
@ -6,7 +6,7 @@ all:
|
||||
|
||||
export PERLLIB=../src
|
||||
|
||||
check: lock_file.test calendar_event_test.test convert_size_test.test procfs_tests.test
|
||||
check: lock_file.test calendar_event_test.test convert_size_test.test procfs_tests.test format_test.test
|
||||
for d in $(SUBDIRS); do $(MAKE) -C $$d check; done
|
||||
|
||||
%.test: %.pl
|
||||
|
27
test/format_test.pl
Executable file
27
test/format_test.pl
Executable file
@ -0,0 +1,27 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use lib '../src';
|
||||
use PVE::JSONSchema;
|
||||
|
||||
use Test::More;
|
||||
use Test::MockModule;
|
||||
|
||||
my $valid_configids = [
|
||||
'aa', 'a0', 'a_', 'a-', 'a-a', 'a'x100, 'Aa', 'AA',
|
||||
];
|
||||
my $invalid_configids = [
|
||||
'a', 'a+', '1a', '_a', '-a', '+a', 'A',
|
||||
];
|
||||
|
||||
my $noerr = 1; # easier to test
|
||||
foreach my $id (@$valid_configids) {
|
||||
is(PVE::JSONSchema::pve_verify_configid($id, $noerr), $id, 'valid configid');
|
||||
}
|
||||
foreach my $id (@$invalid_configids) {
|
||||
is(PVE::JSONSchema::pve_verify_configid($id, $noerr), undef, 'invalid configid');
|
||||
}
|
||||
|
||||
done_testing();
|
Loading…
Reference in New Issue
Block a user