[pve-devel] [PATCH storage 1/4] base plugin: Increase test coverage
Dominic Jäger
d.jaeger at proxmox.com
Thu Apr 9 10:38:43 CEST 2020
On Thu, Apr 09, 2020 at 09:37:37AM +0200, Alwin Antreich wrote:
> On Thu, Apr 02, 2020 at 01:34:11PM +0200, Dominic Jäger wrote:
> > Signed-off-by: Dominic Jäger <d.jaeger at proxmox.com>
> > +
> > +is (($plugin->parse_volname($iso_volname))[$type_index],
> > + $iso_type, 'parse_volname: type for iso');
> > +is (($plugin->parse_volname($iso_volname))[$notdir_index],
> > + $iso_notdir, 'parse_volname: notdir for iso');
> > +
> > +is (($plugin->parse_volname($vztmpl_volname))[$type_index],
> > + $vztmpl_type, 'parse_volname: type for vztmpl');
> > +is (($plugin->parse_volname($vztmpl_volname))[$notdir_index],
> > + $vztmpl_notdir, 'parse_volname: notdir for vztmpl');
> > +
> > +is (($plugin->parse_volname($raw_image_volname))[$type_index],
> > + $image_type, 'parse_volname: type for raw image');
> > +is (($plugin->parse_volname($raw_image_volname))[$notdir_index],
> > + $raw_image_notdir, 'parse_volname: notdir for raw image');
> > +is (($plugin->parse_volname($raw_image_volname))[$format_index],
> > + $raw_image_format, 'parse_volname: format for raw image');
> > +
> > +is (($plugin->parse_volname($qcow_image_volname))[$type_index],
> > + $image_type, 'parse_volname: type for qcow image');
> > +is (($plugin->parse_volname($qcow_image_volname))[$notdir_index],
> > + $qcow_image_notdir, 'parse_volname: notdir for qcow image');
> > +is (($plugin->parse_volname($qcow_image_volname))[$format_index],
> > + $qcow_image_format, 'parse_volname: format for qcow image');
> > +
> > +is (($plugin->parse_volname($vmdk_image_volname))[$type_index],
> > + $image_type, 'parse_volname: type for vmdk image');
> > +is (($plugin->parse_volname($vmdk_image_volname))[$notdir_index],
> > + $vmdk_image_notdir, 'parse_volname: notdir for vmdk image');
> > +is (($plugin->parse_volname($vmdk_image_volname))[$format_index],
> > + $vmdk_image_format, 'parse_volname: format for vmdk image');
> > +
> > +my $scfg_no_rec = { path => $storage_dir_no_rec };
> > +test_list_volumes($scfg_no_rec, [$iso_type], [$iso_volname]);
> > +test_list_volumes($scfg_no_rec, [$vztmpl_type], [$vztmpl_volname]);
> > +
> > +my $scfg_with_type = { path => $storage_dir_no_rec, type => 'dir' };
> > +my $plugin_mock = Test::MockModule->new('PVE::Cluster');
> > +$plugin_mock->redefine('get_vmlist' => sub { return undef });
> > +my $expected_volnames_guests = [$qcow_image_volname, $raw_image_volname,
> > + $vmdk_image_volname];
> > +note 'Tests for undefined VM type => KVM/Qemu';
> > +test_list_volumes($scfg_with_type, ['images'], $expected_volnames_guests);
> > +test_list_volumes($scfg_with_type, ['rootdir'], []);
> > +test_list_volumes($scfg_with_type, ['images', 'rootdir'],
> > + $expected_volnames_guests);
> > +
> > +note 'Tests for VM type lxc';
> > +$plugin_mock->redefine('get_vmlist' => sub
> > + { return { ids => { $vmid => { type => 'lxc' }}}});
> > +test_list_volumes($scfg_with_type, ['images'], []);
> > +test_list_volumes($scfg_with_type, ['rootdir'], $expected_volnames_guests);
> > +test_list_volumes($scfg_with_type, ['images', 'rootdir'],
> > + $expected_volnames_guests);
> > --
> > 2.20.1
> It seems to me, that we both wrote a test for list_volumes. :)
>
> https://pve.proxmox.com/pipermail/pve-devel/2020-April/042888.html
And parse_volname, too
https://pve.proxmox.com/pipermail/pve-devel/2020-April/042883.html
More information about the pve-devel
mailing list