From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 914AC984E3 for ; Wed, 15 Nov 2023 10:44:25 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 743C92B5D for ; Wed, 15 Nov 2023 10:44:25 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Wed, 15 Nov 2023 10:44:24 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id B65F642F66 for ; Wed, 15 Nov 2023 10:44:24 +0100 (CET) Date: Wed, 15 Nov 2023 10:44:23 +0100 From: Wolfgang Bumiller To: Dominik Csapak Cc: pve-devel@lists.proxmox.com Message-ID: References: <20231114103340.2850162-1-d.csapak@proxmox.com> <20231114103340.2850162-5-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231114103340.2850162-5-d.csapak@proxmox.com> X-SPAM-LEVEL: Spam detection results: 0 AWL 0.101 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - Subject: Re: [pve-devel] [PATCH common 4/4] section config: add tests for separated property lists X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Nov 2023 09:44:25 -0000 On Tue, Nov 14, 2023 at 11:33:39AM +0100, Dominik Csapak wrote: > more or less a copy from the normal section config test, but now with > properties defined multiple times as well as conflicting options > > Signed-off-by: Dominik Csapak > --- > test/Makefile | 1 + > test/section_config_separated_test.pl | 486 ++++++++++++++++++++++++++ > 2 files changed, 487 insertions(+) > create mode 100755 test/section_config_separated_test.pl > > diff --git a/test/Makefile b/test/Makefile > index 82f40ab..3e9fef2 100644 > --- a/test/Makefile > +++ b/test/Makefile > @@ -6,6 +6,7 @@ TESTS = lock_file.test \ > format_test.test \ > section_config_test.test \ > api_parameter_test.test \ > + section_config_separated_test.test\ > > all: > > diff --git a/test/section_config_separated_test.pl b/test/section_config_separated_test.pl > new file mode 100755 > index 0000000..234f444 > --- /dev/null > +++ b/test/section_config_separated_test.pl > @@ -0,0 +1,486 @@ > +#!/usr/bin/perl > + > +use lib '../src'; > + > +package Conf; > +use strict; > +use warnings; > + > +use Test::More; > + > +use base qw(PVE::SectionConfig); > + > +my $defaultData = { > + propertyList => { > + type => { description => "Section type." }, > + id => { > + description => "ID", > + type => 'string', > + format => 'pve-configid', > + maxLength => 64, > + }, > + common => { > + type => 'string', > + description => 'common value', > + maxLength => 512, > + }, > + }, > + options => { > + id => {}, > + type => {}, > + }, > +}; > + > +sub private { > + return $defaultData; > +} > + > +sub expect_success { > + my ($class, $filename, $expected, $raw, $allow_unknown) = @_; > + > + my $res = $class->parse_config($filename, $raw, $allow_unknown); > + delete $res->{digest}; > + > + is_deeply($res, $expected, $filename); > + > + my $written = $class->write_config($filename, $res, $allow_unknown); > + my $res2 = $class->parse_config($filename, $written, $allow_unknown); > + delete $res2->{digest}; > + > + is_deeply($res, $res2, "$filename - verify rewritten data"); > +} > + > +sub expect_fail { > + my ($class, $filename, $expected, $raw) = @_; > + > + eval { $class->parse_config($filename, $raw) }; > + die "test '$filename' succeeded unexpectedly\n" if !$@; > + ok(1, "$filename should fail to parse"); > +} > + > +package Conf::One; > +use strict; > +use warnings; > + > +use base 'Conf'; > + > +sub type { > + return 'one'; > +} > + > +sub properties { > + return { > + field1 => { > + description => 'Field One', > + type => 'integer', > + minimum => 3, > + maximum => 9, > + }, > + another => { > + description => 'Another field', > + type => 'string', > + }, > + field2 => { > + description => 'Field Two', > + type => 'integer', > + minimum => 10, > + maximum => 19, > + } > + }; > +} > + > +sub options { > + return { > + common => { optional => 1 }, > + field1 => {}, > + field2 => {}, > + another => { optional => 1 }, > + arrayfield => { optional => 1, type => 'two' }, Oh... *That's* how you use `type` here... Can we not? I'd *really* prefer to just have `arrayfield` copied into the properties right here. Changing an existing property currently requires us to consider all the types it appears in. I thought we could now have *distinct* schemas for them without *also* having to worry about potential reuse from somewhere else :S