public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH pve-common 1/3 v2] Add tests for verify_configid
@ 2020-10-28 10:04 Dominic Jäger
  2020-10-28 10:04 ` [pve-devel] [PATCH pve-common 2/3 v2] Make configid regex public Dominic Jäger
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Dominic Jäger @ 2020-10-28 10:04 UTC (permalink / raw)
  To: pve-devel

Signed-off-by: Dominic Jäger <d.jaeger@proxmox.com>
---
v1->v2: Didn't exist

 test/Makefile       |  2 +-
 test/format_test.pl | 27 +++++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 1 deletion(-)
 create mode 100755 test/format_test.pl

diff --git a/test/Makefile b/test/Makefile
index b8118c7..85ecac5 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -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
diff --git a/test/format_test.pl b/test/format_test.pl
new file mode 100755
index 0000000..3f225de
--- /dev/null
+++ b/test/format_test.pl
@@ -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();
\ No newline at end of file
-- 
2.20.1




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-11-16 17:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-28 10:04 [pve-devel] [PATCH pve-common 1/3 v2] Add tests for verify_configid Dominic Jäger
2020-10-28 10:04 ` [pve-devel] [PATCH pve-common 2/3 v2] Make configid regex public Dominic Jäger
2020-10-29 18:15   ` [pve-devel] applied: " Thomas Lamprecht
2020-10-28 10:04 ` [pve-devel] [PATCH pve-storage 3/3 v2] lvmthin: Match snapshot remove regex to allowed names Dominic Jäger
2020-11-16 17:26   ` [pve-devel] applied: " Thomas Lamprecht
2020-10-29 18:15 ` [pve-devel] applied: [PATCH pve-common 1/3 v2] Add tests for verify_configid Thomas Lamprecht

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal