mirror of
https://github.com/XRPLF/clio.git
synced 2025-12-06 17:27:58 +00:00
feat: Cache state endpoint (#2642)
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
#include "app/WebHandlers.hpp"
|
||||
#include "rpc/Errors.hpp"
|
||||
#include "util/AsioContextTestFixture.hpp"
|
||||
#include "util/MockLedgerCache.hpp"
|
||||
#include "util/MockPrometheus.hpp"
|
||||
#include "util/Taggable.hpp"
|
||||
#include "util/config/ConfigDefinition.hpp"
|
||||
@@ -149,6 +150,32 @@ TEST_F(HealthCheckHandlerTests, Call)
|
||||
});
|
||||
}
|
||||
|
||||
struct CacheStateHandlerTests : SyncAsioContextTest, WebHandlersTest {
|
||||
web::ng::Request request{http::request<http::string_body>{http::verb::get, "/", 11}};
|
||||
MockLedgerCache cache;
|
||||
CacheStateHandler cacheStateHandler{cache};
|
||||
};
|
||||
|
||||
TEST_F(CacheStateHandlerTests, CallWithCacheLoaded)
|
||||
{
|
||||
EXPECT_CALL(cache, isFull()).WillRepeatedly(testing::Return(true));
|
||||
runSpawn([&](boost::asio::yield_context yield) {
|
||||
auto response = cacheStateHandler(request, connectionMock, nullptr, yield);
|
||||
auto const httpResponse = std::move(response).intoHttpResponse();
|
||||
EXPECT_EQ(httpResponse.result(), boost::beast::http::status::ok);
|
||||
});
|
||||
}
|
||||
|
||||
TEST_F(CacheStateHandlerTests, CallWithoutCacheLoaded)
|
||||
{
|
||||
EXPECT_CALL(cache, isFull()).WillRepeatedly(testing::Return(false));
|
||||
runSpawn([&](boost::asio::yield_context yield) {
|
||||
auto response = cacheStateHandler(request, connectionMock, nullptr, yield);
|
||||
auto const httpResponse = std::move(response).intoHttpResponse();
|
||||
EXPECT_EQ(httpResponse.result(), boost::beast::http::status::service_unavailable);
|
||||
});
|
||||
}
|
||||
|
||||
struct RequestHandlerTest : SyncAsioContextTest, WebHandlersTest {
|
||||
AdminVerificationStrategyStrictMockPtr adminVerifier{
|
||||
std::make_shared<testing::StrictMock<AdminVerificationStrategyMock>>()
|
||||
|
||||
Reference in New Issue
Block a user