Files
logos-liblogos/tests/test_qt_plugin_runtime.cpp

91 lines
2.9 KiB
C++
Raw Permalink Normal View History

// =============================================================================
// Tests for QtPluginRuntime — the ModuleLoader implementation that knows how
// to resolve logos_host_qt and build its CLI arguments.
//
// These are pure unit tests: no processes spawned, no filesystem side-effects.
// =============================================================================
#include <gtest/gtest.h>
#include "runtimes/runtime_qt/qt_plugin_runtime.h"
class QtPluginRuntimeTest : public ::testing::Test {
protected:
QtPluginRuntime loader;
};
// ---------------------------------------------------------------------------
// id
// ---------------------------------------------------------------------------
TEST_F(QtPluginRuntimeTest, Id_ReturnsQtPlugin) {
EXPECT_EQ(loader.id(), "qt-plugin");
}
// ---------------------------------------------------------------------------
// canHandle
// ---------------------------------------------------------------------------
TEST_F(QtPluginRuntimeTest, CanHandle_AcceptsQtPluginFormat) {
LogosCore::ModuleDescriptor desc;
desc.format = "qt-plugin";
EXPECT_TRUE(loader.canHandle(desc));
}
TEST_F(QtPluginRuntimeTest, CanHandle_AcceptsEmptyFormat) {
LogosCore::ModuleDescriptor desc;
desc.format = "";
EXPECT_TRUE(loader.canHandle(desc));
}
TEST_F(QtPluginRuntimeTest, CanHandle_RejectsWasmFormat) {
LogosCore::ModuleDescriptor desc;
desc.format = "wasm";
EXPECT_FALSE(loader.canHandle(desc));
}
TEST_F(QtPluginRuntimeTest, CanHandle_RejectsArbitraryFormat) {
LogosCore::ModuleDescriptor desc;
desc.format = "extism";
EXPECT_FALSE(loader.canHandle(desc));
}
// ---------------------------------------------------------------------------
// buildArguments
// ---------------------------------------------------------------------------
TEST_F(QtPluginRuntimeTest, BuildArguments_IncludesNameAndPath) {
LogosCore::ModuleDescriptor desc;
desc.name = "my_module";
desc.path = "/opt/modules/my_module_plugin.so";
auto args = loader.buildArguments(desc);
ASSERT_GE(args.size(), 4u);
EXPECT_EQ(args[0], "--name");
EXPECT_EQ(args[1], "my_module");
EXPECT_EQ(args[2], "--path");
EXPECT_EQ(args[3], "/opt/modules/my_module_plugin.so");
}
TEST_F(QtPluginRuntimeTest, BuildArguments_IncludesInstancePersistencePath) {
LogosCore::ModuleDescriptor desc;
desc.name = "persisted";
desc.path = "/lib/persisted.so";
desc.instancePersistencePath = "/var/logos/instances/abc123";
auto args = loader.buildArguments(desc);
ASSERT_EQ(args.size(), 6u);
EXPECT_EQ(args[4], "--instance-persistence-path");
EXPECT_EQ(args[5], "/var/logos/instances/abc123");
}
TEST_F(QtPluginRuntimeTest, BuildArguments_OmitsInstancePersistenceWhenEmpty) {
LogosCore::ModuleDescriptor desc;
desc.name = "simple";
desc.path = "/lib/simple.so";
auto args = loader.buildArguments(desc);
EXPECT_EQ(args.size(), 4u);
}