Skip to content

Commit

Permalink
test(schema): restore dummy schema test, ref #149
Browse files Browse the repository at this point in the history
  • Loading branch information
iboB committed Dec 3, 2024
1 parent db2035c commit 0f0e265
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 16 deletions.
18 changes: 9 additions & 9 deletions dummy-plugin/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ add_doctest_test(aclp-dummy-plib
ac::jalog
)

# add_doctest_test(aclp-dummy-schema
# SOURCES
# t-dummy-schema.cpp
# LIBRARIES
# ac-dev::test-util
# aclp::dummy-plib
# ac-test-data::dummy
# ac::jalog
# )
add_doctest_test(aclp-dummy-schema
SOURCES
t-dummy-schema.cpp
LIBRARIES
ac-dev::test-util
aclp-dummy-baselib
ac-test-data::dummy
ac::jalog
)

add_doctest_test(aclp-dummy-plugin
SOURCES
Expand Down
21 changes: 16 additions & 5 deletions dummy-plugin/test/t-dummy-schema.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,23 @@

#include <ac/schema/CallHelpers.hpp>

#include <ac/local/PluginPlibUtil.inl>

#include <ac/dummy/LocalDummy.hpp>
#include <ac/dummy/DummyLoaderSchema.hpp>

#include <ac-test-util/JalogFixture.inl>

#include <doctest/doctest.h>

#include <aclp-dummy-plib.hpp>
#include <ac-test-data-dummy-models.h>

struct LoadDummyFixture {
LoadDummyFixture() {
add_dummy_to_ac_local_global_registry();
PlibHelper helper;
LoadDummyFixture()
: helper(ac::dummy::getPluginInterface())
{
helper.addLoadersToGlobalRegistry();
}
};

Expand All @@ -31,8 +38,12 @@ TEST_CASE("dummy schema") {

REQUIRE(!!model);

using Instance = ac::local::schema::Dummy::InstanceGeneral;
using Instance = ac::local::schema::DummyLoader::InstanceGeneral;
auto instance = Model_createInstance<Instance>(*model, {.cutoff = 2});
auto result = Instance_runOp<Instance::OpRun>(*instance, {.input = {"a", "b", "c"}});

using Interface = ac::local::schema::DummyInterface;
auto result = Instance_runOp<Interface::OpRun>(*instance,
{.input = std::vector<std::string>{"a", "b", "c"}}
);
CHECK(result.result == "a one b two c one");
}
7 changes: 5 additions & 2 deletions schema/code/ac/schema/CallHelpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: MIT
//
#pragma once
#include "IOVisitors.hpp"
#include <ac/local/Model.hpp>
#include <ac/local/Instance.hpp>
#include <utility>
Expand All @@ -10,12 +11,14 @@ namespace ac::local {

template <typename Instance>
auto Model_createInstance(Model& model, typename Instance::Params p) {
return model.createInstance(Instance::id, p.toDict());
return model.createInstance(Instance::id, schema::Struct_toDict(std::move(p)));
}

template <typename Op>
typename Op::Return Instance_runOp(Instance& instance, typename Op::Params p, ProgressCb cb = {}) {
return Op::Return::fromDict(instance.runOp(Op::id, p.toDict(), std::move(cb)));
return schema::Struct_fromDict<typename Op::Return>(
instance.runOp(Op::id, schema::Struct_toDict(std::move(p)), std::move(cb))
);
}

} // namespace ac::local

0 comments on commit 0f0e265

Please sign in to comment.