Skip to content

Commit

Permalink
Fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaute Lindkvist committed Mar 14, 2024
1 parent 7624bdb commit 9e6fe24
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions RestInterface/cafRestClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ void RestClient::sendKeepAlive()
std::string( "/sessions/" ) + m_sessionUuid + "?session_uuid=" + m_sessionUuid,
"" );

if ( status != http::status::accepted )
if ( status != http::status::accepted && status != http::status::ok )
{
throw std::runtime_error( "Failed to keep server alive: " + body );
}
Expand Down Expand Up @@ -523,7 +523,7 @@ caffa::Session::Type RestClient::checkSession() const

auto jsonResult = nlohmann::json::parse( body );
CAFFA_ASSERT( jsonResult.contains( "type" ) );
return static_cast<caffa::Session::Type>( jsonResult["type"].get<unsigned>() );
return caffa::AppEnum<caffa::Session::Type>::fromLabel( jsonResult["type"].get<std::string>() ).value();
}

//--------------------------------------------------------------------------------------------------
Expand All @@ -535,7 +535,7 @@ void RestClient::changeSession( caffa::Session::Type newType )

auto jsonObject = nlohmann::json::object();
jsonObject["uuid"] = m_sessionUuid;
jsonObject["type"] = static_cast<unsigned>( newType );
jsonObject["type"] = caffa::AppEnum<caffa::Session::Type>( newType ).label();

auto [status, body] = performRequest( http::verb::put,
hostname(),
Expand Down
2 changes: 1 addition & 1 deletion RestInterface/cafRestSessionService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ RestSessionService::ServiceResponse RestSessionService::changeOrKeepAlive( const
}
auto jsonResponse = nlohmann::json::object();
jsonResponse["uuid"] = session->uuid();
jsonResponse["type"] = static_cast<unsigned>( session->type() );
jsonResponse["type"] = caffa::AppEnum<caffa::Session::Type>::label( session->type() );
jsonResponse["valid"] = !session->isExpired();

return std::make_tuple( http::status::ok, jsonResponse.dump(), nullptr );
Expand Down

0 comments on commit 9e6fe24

Please sign in to comment.