59 lines
1.4 KiB
C++
59 lines
1.4 KiB
C++
#include <gmock/gmock.h>
|
|
#include <gtest/gtest.h>
|
|
|
|
#include "../src/rublon.hpp"
|
|
|
|
#include "core_response_generator.hpp"
|
|
|
|
using namespace rublon;
|
|
using namespace testing;
|
|
|
|
namespace {
|
|
Configuration conf;
|
|
}
|
|
|
|
class CoreHandlerMock : public CoreHandlerInterface< CoreHandlerMock > {
|
|
public:
|
|
CoreHandlerMock() {}
|
|
|
|
MOCK_METHOD(( tl::expected< Document, CoreHandlerError > ), request, ( std::string_view, const Document & ), (const));
|
|
|
|
CoreHandlerMock & statusPending() {
|
|
gen.status = "pending";
|
|
return *this;
|
|
}
|
|
|
|
CoreHandlerMock & brokenBody() {
|
|
gen.generateBrokenData = true;
|
|
return *this;
|
|
}
|
|
|
|
operator tl::expected< Document, CoreHandlerError >() {
|
|
auto body = gen.generateBody();
|
|
|
|
rublon::Document doc;
|
|
doc.Parse(body.c_str());
|
|
|
|
return doc;
|
|
}
|
|
|
|
CoreResponseGenerator gen;
|
|
};
|
|
|
|
class RublonHttpInitTest : public testing::Test {
|
|
public:
|
|
CoreHandlerMock coreHandler;
|
|
Init<> sut{conf};
|
|
};
|
|
|
|
using CoreReturn = tl::expected< Document, CoreHandlerError >;
|
|
|
|
TEST_F(RublonHttpInitTest, initializationSendsRequestOnGoodPath) {
|
|
EXPECT_CALL(coreHandler, request("/api/transaction/init", _)).WillOnce(Return(tl::unexpected{CoreHandlerError{CoreHandlerError::BadSigature}}));
|
|
sut.handle(coreHandler);
|
|
}
|
|
|
|
TEST_F(RublonHttpInitTest, returnMethods){
|
|
|
|
}
|