-
Notifications
You must be signed in to change notification settings - Fork 657
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[tests] Adapt LXD mount tests to instance_dir
Account for instance directories in new tests, after rebasing. Signed-off-by: sharder996 <[email protected]>
- Loading branch information
1 parent
f8652cb
commit b1ef49d
Showing
1 changed file
with
19 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,9 +22,11 @@ | |
#include "tests/mock_virtual_machine.h" | ||
#include "tests/stub_ssh_key_provider.h" | ||
#include "tests/stub_status_monitor.h" | ||
#include "tests/temp_dir.h" | ||
|
||
#include "src/platform/backends/lxd/lxd_mount_handler.h" | ||
|
||
#include <multipass/path.h> | ||
#include <multipass/utils.h> | ||
#include <multipass/virtual_machine_description.h> | ||
#include <multipass/vm_mount.h> | ||
|
@@ -40,8 +42,9 @@ class MockLXDVirtualMachine : public mpt::MockVirtualMachineT<mp::LXDVirtualMach | |
public: | ||
MockLXDVirtualMachine(const mp::VirtualMachineDescription& desc, mp::VMStatusMonitor& monitor, | ||
mp::NetworkAccessManager* manager, const QUrl& base_url, const QString& bridge_name, | ||
const QString& storage_pool) | ||
: mpt::MockVirtualMachineT<mp::LXDVirtualMachine>{desc, monitor, manager, base_url, bridge_name, storage_pool} | ||
const QString& storage_pool, const mp::Path& instance_dir) | ||
: mpt::MockVirtualMachineT<mp::LXDVirtualMachine>{desc, monitor, manager, base_url, | ||
bridge_name, storage_pool, instance_dir} | ||
{ | ||
} | ||
}; | ||
|
@@ -73,6 +76,8 @@ struct LXDMountHandlerTestFixture : public testing::Test | |
|
||
mpt::MockLogger::Scope logger_scope = mpt::MockLogger::inject(); | ||
|
||
mpt::TempDir instance_dir; | ||
|
||
const mpt::StubSSHKeyProvider key_provider; | ||
const mp::VMMount vm_mount{source_path, {}, {}, mp::VMMount::MountType::Native}; | ||
const QUrl base_url{"unix:///[email protected]"}; | ||
|
@@ -108,7 +113,8 @@ struct LXDMountHandlerValidGidUidParameterTests : public LXDMountHandlerTestFixt | |
TEST_F(LXDMountHandlerTestFixture, startDoesNotThrowIfVMIsStopped) | ||
{ | ||
NiceMock<MockLXDVirtualMachine> lxd_vm{ | ||
default_description, stub_monitor, &mock_network_access_manager, base_url, bridge_name, default_storage_pool}; | ||
default_description, stub_monitor, &mock_network_access_manager, base_url, | ||
bridge_name, default_storage_pool, instance_dir.path()}; | ||
|
||
mp::LXDMountHandler lxd_mount_handler(&mock_network_access_manager, &lxd_vm, &key_provider, target_path, vm_mount); | ||
|
||
|
@@ -121,7 +127,8 @@ TEST_F(LXDMountHandlerTestFixture, startDoesNotThrowIfVMIsStopped) | |
TEST_F(LXDMountHandlerTestFixture, startThrowsIfVMIsRunning) | ||
{ | ||
NiceMock<MockLXDVirtualMachine> lxd_vm{ | ||
default_description, stub_monitor, &mock_network_access_manager, base_url, bridge_name, default_storage_pool}; | ||
default_description, stub_monitor, &mock_network_access_manager, base_url, | ||
bridge_name, default_storage_pool, instance_dir.path()}; | ||
mp::LXDMountHandler lxd_mount_handler(&mock_network_access_manager, &lxd_vm, &key_provider, target_path, vm_mount); | ||
|
||
EXPECT_CALL(lxd_vm, current_state).WillOnce(Return(multipass::VirtualMachine::State::running)); | ||
|
@@ -134,7 +141,8 @@ TEST_F(LXDMountHandlerTestFixture, startThrowsIfVMIsRunning) | |
TEST_F(LXDMountHandlerTestFixture, stopDoesNotThrowIfVMIsStopped) | ||
{ | ||
NiceMock<MockLXDVirtualMachine> lxd_vm{ | ||
default_description, stub_monitor, &mock_network_access_manager, base_url, bridge_name, default_storage_pool}; | ||
default_description, stub_monitor, &mock_network_access_manager, base_url, | ||
bridge_name, default_storage_pool, instance_dir.path()}; | ||
mp::LXDMountHandler lxd_mount_handler(&mock_network_access_manager, &lxd_vm, &key_provider, target_path, vm_mount); | ||
|
||
EXPECT_CALL(lxd_vm, current_state) | ||
|
@@ -149,7 +157,8 @@ TEST_F(LXDMountHandlerTestFixture, stopDoesNotThrowIfVMIsStopped) | |
TEST_F(LXDMountHandlerTestFixture, stopThrowsIfVMIsRunning) | ||
{ | ||
NiceMock<MockLXDVirtualMachine> lxd_vm{ | ||
default_description, stub_monitor, &mock_network_access_manager, base_url, bridge_name, default_storage_pool}; | ||
default_description, stub_monitor, &mock_network_access_manager, base_url, | ||
bridge_name, default_storage_pool, instance_dir.path()}; | ||
|
||
mp::LXDMountHandler lxd_mount_handler(&mock_network_access_manager, &lxd_vm, &key_provider, target_path, vm_mount); | ||
|
||
|
@@ -165,8 +174,8 @@ TEST_F(LXDMountHandlerTestFixture, stopThrowsIfVMIsRunning) | |
|
||
TEST_P(LXDMountHandlerInvalidGidUidParameterTests, mountWithGidOrUid) | ||
{ | ||
mp::LXDVirtualMachine lxd_vm{default_description, stub_monitor, &mock_network_access_manager, base_url, | ||
bridge_name, default_storage_pool}; | ||
mp::LXDVirtualMachine lxd_vm{default_description, stub_monitor, &mock_network_access_manager, base_url, | ||
bridge_name, default_storage_pool, instance_dir.path()}; | ||
const auto& [host_gid, instance_gid, host_uid, instance_uid] = GetParam(); | ||
const mp::VMMount vm_mount{ | ||
source_path, {{host_gid, instance_gid}}, {{host_uid, instance_uid}}, mp::VMMount::MountType::Native}; | ||
|
@@ -182,8 +191,8 @@ INSTANTIATE_TEST_SUITE_P(mountWithGidOrUidInstantiation, LXDMountHandlerInvalidG | |
|
||
TEST_P(LXDMountHandlerValidGidUidParameterTests, mountWithGidOrUid) | ||
{ | ||
mp::LXDVirtualMachine lxd_vm{default_description, stub_monitor, &mock_network_access_manager, base_url, | ||
bridge_name, default_storage_pool}; | ||
mp::LXDVirtualMachine lxd_vm{default_description, stub_monitor, &mock_network_access_manager, base_url, | ||
bridge_name, default_storage_pool, instance_dir.path()}; | ||
const auto& [host_gid, host_uid] = GetParam(); | ||
const int default_instance_id = -1; | ||
const mp::VMMount vm_mount{source_path, | ||
|