Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/metrics_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@ MetricsImpl::MetricsImpl(Firebolt::Helpers::IHelper& helper)

Result<void> MetricsImpl::ready() const
{
return helper_.invoke("Metrics.ready", nlohmann::json({}));
return helper_.invoke("Metrics.ready", nlohmann::json());
}

Result<void> MetricsImpl::signIn() const
{
return helper_.invoke("Metrics.signIn", nlohmann::json({}));
return helper_.invoke("Metrics.signIn", nlohmann::json());
}

Result<void> MetricsImpl::signOut() const
{
return helper_.invoke("Metrics.signOut", nlohmann::json({}));
return helper_.invoke("Metrics.signOut", nlohmann::json());
}

Result<void> MetricsImpl::startContent(const std::optional<std::string>& entityId,
Expand Down
19 changes: 17 additions & 2 deletions test/unit/mock_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,23 @@ class MockBase
void mockInvoke(const std::string& methodName)
{
EXPECT_CALL(mockHelper, invoke(methodName, _))
.WillOnce(Invoke([](const std::string& /*methodName*/, const nlohmann::json& /*parameters*/)
{ return Firebolt::Result<void>{Firebolt::Error::None}; }));
.WillOnce(Invoke(
[&](const std::string& invokedMethodName, const nlohmann::json& parameters)
{
nlohmann::json message = {
{"jsonrpc", "2.0"},
{"id", "0"},
{"method", invokedMethodName},
};

if (!parameters.is_null())
{
message["params"] = parameters;
}

Firebolt::Error err = jsonEngine.MockResponse(message);
return Firebolt::Result<void>{err};
}));
}

void mockSubscribe(const std::string& eventName)
Expand Down
8 changes: 4 additions & 4 deletions test/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ void verifyUnsubscribeResult(const Firebolt::Result<void>& result)
FAIL() << "Unsubscribe failed." + toError(result);
}
}
void verifyEventReceived(std::mutex& mtx, std::condition_variable& cv, const bool& eventReceived)
void verifyEventReceived(std::mutex& mtx, std::condition_variable& cv, bool& eventReceived)
{
std::unique_lock<std::mutex> lock(mtx);
if (!cv.wait_for(lock, EventWaitTime, [&] { return eventReceived; }))
Expand All @@ -134,11 +134,11 @@ void verifyEventReceived(std::mutex& mtx, std::condition_variable& cv, const boo
}
}

void verifyEventNotReceived(std::mutex& mtx, std::condition_variable& cv, const bool& eventReceived)
void verifyEventNotReceived(std::mutex& mtx, std::condition_variable& cv, bool& eventReceived)
{
// Wait for the event to be received or timeout after 5 seconds
// Wait for the event to be received or timeout after EventWaitTime.
std::unique_lock<std::mutex> lock(mtx);
if (cv.wait_for(lock, std::chrono::seconds(EventWaitTime), [&] { return eventReceived; }))
if (cv.wait_for(lock, EventWaitTime, [&] { return eventReceived; }))
{
FAIL() << "Unexpectedly received event";
}
Expand Down
4 changes: 2 additions & 2 deletions test/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ void triggerRaw(const std::string& payload);

void verifyEventSubscription(const Firebolt::Result<Firebolt::SubscriptionId>& id);
void verifyUnsubscribeResult(const Firebolt::Result<void>& result);
void verifyEventReceived(std::mutex& mtx, std::condition_variable& cv, const bool& eventReceived);
void verifyEventNotReceived(std::mutex& mtx, std::condition_variable& cv, const bool& eventReceived);
void verifyEventReceived(std::mutex& mtx, std::condition_variable& cv, bool& eventReceived);
void verifyEventNotReceived(std::mutex& mtx, std::condition_variable& cv, bool& eventReceived);

template <typename T> inline std::string toError(const Firebolt::Result<T>& result)
{
Expand Down
Loading