Skip to content

Commit

Permalink
add tests for "hyper-v" and "vbox" cases
Browse files Browse the repository at this point in the history
  • Loading branch information
levkropp committed Sep 10, 2024
1 parent ed07c9e commit 5b25bd9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/daemon/daemon_init_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ QString driver_interpreter(QString val)

if (val == QStringLiteral("hyper-v"))
val = QStringLiteral("hyperv");

if (val == QStringLiteral("vbox"))
else if (val == QStringLiteral("vbox"))
val = QStringLiteral("virtualbox");

if (!MP_PLATFORM.is_backend_supported(val))
Expand Down
26 changes: 26 additions & 0 deletions tests/test_global_settings_handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,32 @@ TEST_F(TestGlobalSettingsHandlers, daemonRegistersHandlerThatAcceptsValidBackend
ASSERT_NO_THROW(handler->set(key, val));
}

TEST_F(TestGlobalSettingsHandlers, daemonRegistersHandlerThatTransformsHyperVDriver)
{
auto key = mp::driver_key, val = "hyper-v";
auto transformed_val = "hyperv";

mp::daemon::register_global_settings_handlers();

EXPECT_CALL(*mock_qsettings, setValue(Eq(key), Eq(transformed_val)));
inject_mock_qsettings();

ASSERT_NO_THROW(handler->set(key, val));
}

TEST_F(TestGlobalSettingsHandlers, daemonRegistersHandlerThatTransformsVBoxDriver)
{
auto key = mp::driver_key, val = "vbox";
auto transformed_val = "virtualbox";

mp::daemon::register_global_settings_handlers();

EXPECT_CALL(*mock_qsettings, setValue(Eq(key), Eq(transformed_val)));
inject_mock_qsettings();

ASSERT_NO_THROW(handler->set(key, val));
}

TEST_F(TestGlobalSettingsHandlers, daemonRegistersHandlerThatRejectsInvalidBackend)
{
auto key = mp::driver_key, val = "bad driver";
Expand Down

0 comments on commit 5b25bd9

Please sign in to comment.