Skip to content

Commit

Permalink
Native SDK events unit tests initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
parag-pv committed Oct 2, 2024
1 parent ca09400 commit 3704c1d
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions languages/cpp/src/shared/src/Transport/Transport.h
Original file line number Diff line number Diff line change
Expand Up @@ -962,11 +962,25 @@ namespace FireboltSDK
}
return FireboltErrorValue(result);
}

#ifdef UNIT_TEST
template <typename RESPONSE>
Firebolt::Error WaitForEventResponse(const uint32_t &id, const string &eventName, RESPONSE &response, const uint32_t waitTime, EventMap& _eventMap)
{
std::cout << "Inside Mock Transport WaitForEventResponse function" << std::endl;
std::cout << "Mock Transport WaitForEventResponse eventName: " << eventName << std::endl;
/* We could optionally return a response inside WaitForEventResponse using JSON engine's mockResponse
pointing to #/x-schemas/Types/ListenResponse dereferenced to "{listening:true}".
Since there is no return value for event subscription, error would be the only validation for now.
Ideally, the event response should be returned here after the event is triggered.
*/
return Firebolt::Error::None;
}
#else
static constexpr uint32_t WAITSLOT_TIME = 100;
template <typename RESPONSE>
Firebolt::Error WaitForEventResponse(const uint32_t &id, const string &eventName, RESPONSE &response, const uint32_t waitTime, EventMap& _eventMap)
{
std::cout << "Inside Transport WaitForEventResponse function" << std::endl;
Firebolt::Error result = Firebolt::Error::Timedout;
_adminLock.Lock();
typename PendingMap::iterator index = _pendingQueue.find(id);
Expand Down Expand Up @@ -1025,7 +1039,7 @@ namespace FireboltSDK

return result;
}

#endif
public:
void FromMessage(WPEFramework::Core::JSON::IElement *response, const WPEFramework::Core::JSONRPC::Message &message) const
{
Expand Down

0 comments on commit 3704c1d

Please sign in to comment.