public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: "Daniel Kral" <d.kral@proxmox.com>
To: "Elias Huhsovitz" <e.huhsovitz@proxmox.com>,
	<pve-devel@lists.proxmox.com>
Subject: Re: [PATCH access-control 2/2] test: api: add tests for ACL modification endpoint
Date: Thu, 23 Jul 2026 11:28:52 +0200	[thread overview]
Message-ID: <DK5UF2FTN1PV.VBCGB59FBFNR@proxmox.com> (raw)
In-Reply-To: <DK5TTET754VG.59P9HQBZSXYQ@proxmox.com>

On Thu Jul 23, 2026 at 11:00 AM CEST, Elias Huhsovitz wrote:
>>> +}
>>> +
>>> +sub run_update_acl ($params) {
>>> +    my $result = eval { $handler->handle($handler_info, $params) };
>>> +    return ($result, $@);
>>> +}
>>
>> Hm, I wonder whether the test cases would be a little more compact and
>> reviewable by following the usual test case structure which is
>>
>> - defining an array full of hashes where each hash represents a test
>>   case
>> - a loop then goes through each test case
>>
>> Each test case could then make a deep comparison between the resulting
>> $current_cfg->{acl_root}, which is reset for each test case entry.
>>
>> As a proposal for a possible test case entry could be:
>>
>>     {
>>         update_acl_params => { ... },
>>         # can be made empty for specific test cases, etc.
>>         permissions => { 'Permissions.Modify' => 1 },
>>         expected_acl_root => { ... },
>>     }
>>
>> What do you think?
>
> I also like this kind of style.
>
> I used the following guide as a base: https://perlmaven.com/testing
> and it mentioned the subtest keyword here: https://perlmaven.com/subtest
>
> There subtest keyword is also used in some other repositories, such as 
> - pve-container/src/test/snapshot-test.pm
> - qemu-server/src/test/snapshot-test.pm
> - pve-container/src/test/idmap-test.pm
>
> So i was not sure what the preferred approach currently is.
>
> I did it this way, since I am more familiar with JUnit5 as a testing 
> framework. I don't view the additional verbosity as a bad thing in
> this case, since it provides a bit more description and makes it easier
> to modify existing tests in the future.
>
> I appreciate the simplicity of the approach you suggested
> and can implement this style in v2.

Your style is fine as it is, so no hard feelings here ;)

It was just a suggestion because the test cases do similar things it's
nice to factor them so there's less repetition to call before_each() in
each subtest and have similar is() and ok() tests.

If we want to add test cases which test other stuff then it's fine to
add either another test script or another subroutine which handles
another @array full of test cases.




  reply	other threads:[~2026-07-23  9:28 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-20 13:45 [PATCH access-control 0/2] fix: #6510: Allow deleting ACLs for non-existent entities & add API tests Elias Huhsovitz
2026-07-20 13:45 ` [PATCH access-control 1/2] fix #6510: api: acl: allow deleting ACLs for non-existent entities Elias Huhsovitz
2026-07-21 14:40   ` Daniel Kral
2026-07-20 13:45 ` [PATCH access-control 2/2] test: api: add tests for ACL modification endpoint Elias Huhsovitz
2026-07-21 15:20   ` Daniel Kral
2026-07-23  9:00     ` Elias Huhsovitz
2026-07-23  9:28       ` Daniel Kral [this message]
2026-07-23 11:16 ` superseded: [PATCH access-control 0/2] fix: #6510: Allow deleting ACLs for non-existent entities & add API tests Elias Huhsovitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DK5UF2FTN1PV.VBCGB59FBFNR@proxmox.com \
    --to=d.kral@proxmox.com \
    --cc=e.huhsovitz@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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