1
0
Fork 0
mirror of https://github.com/KingDuckZ/kamokan.git synced 2024-12-27 21:35:41 +00:00

Make functions virtual when building with testing.

This commit is contained in:
King_DuckZ 2017-06-05 23:02:39 +01:00
parent c302dbee73
commit fb27563fdd
6 changed files with 23 additions and 10 deletions

View file

@ -60,6 +60,8 @@ target_compile_definitions(${PROJECT_NAME}
PRIVATE BOOST_SPIRIT_USE_PHOENIX_V3=1
PUBLIC $<$<CONFIG:Debug>:SPDLOG_DEBUG_ON>
PUBLIC $<$<CONFIG:Debug>:SPDLOG_TRACE_ON>
PUBLIC tawashi_virtual_testing$<$<BOOL:BUILD_TESTING>:=virtual>
PUBLIC $<$<BOOL:BUILD_TESTING>:TAWASHI_WITH_TESTING>
)
target_compile_options(${PROJECT_NAME}
PRIVATE -fdiagnostics-color=always

View file

@ -17,7 +17,6 @@
#include "response.hpp"
#include "settings_bag.hpp"
#include "tawashi_config.h"
#include "duckhandy/stringize.h"
#include "duckhandy/lexical_cast.hpp"
#include "pathname/pathname.hpp"

View file

@ -51,7 +51,7 @@ namespace tawashi {
const cgi::Env& cgi_env() const;
const std::string& base_uri() const;
virtual boost::string_ref page_basename() const = 0;
const Storage& storage() const;
tawashi_virtual_testing const Storage& storage() const;
const SettingsBag& settings() const;
virtual std::string load_mustache() const;
HttpHeader make_redirect (HttpStatusCodes parCode, const std::string& parLocation);

View file

@ -128,4 +128,10 @@ namespace tawashi {
return pastie;
}
#if defined(TAWASHI_WITH_TESTING)
const SettingsBag& Storage::settings() const {
return *m_settings;
}
#endif
} //namespace tawashi

View file

@ -40,19 +40,23 @@ namespace tawashi {
};
explicit Storage (const Kakoune::SafePtr<SettingsBag>& parSettings);
~Storage();
tawashi_virtual_testing ~Storage();
void connect_async();
bool is_connected() const;
void finalize_connection();
SubmissionResult submit_pastie (
tawashi_virtual_testing void connect_async();
tawashi_virtual_testing bool is_connected() const;
tawashi_virtual_testing void finalize_connection();
tawashi_virtual_testing SubmissionResult submit_pastie (
const boost::string_ref& parText,
uint32_t parExpiry,
const boost::string_ref& parLang,
const std::string& parRemoteIP
) const;
boost::optional<std::string> retrieve_pastie (const boost::string_ref& parToken) const;
tawashi_virtual_testing boost::optional<std::string> retrieve_pastie (const boost::string_ref& parToken) const;
#if defined(TAWASHI_WITH_TESTING)
const SettingsBag& settings() const;
#endif
private:
std::unique_ptr<redis::IncRedis> m_redis;

View file

@ -133,9 +133,11 @@ namespace tawashi {
oss << *token;
if (not lang.empty())
oss << '?' << lang;
statuslog->info("Pastie token=\"{}\" redirect=\"{}\"", *token, oss.str());
return this->make_success_response(oss.str());
std::string redirect = oss.str();
statuslog->info("Pastie token=\"{}\" redirect=\"{}\"", *token, redirect);
return this->make_success_response(std::move(redirect));
}
else {
statuslog->info("Empty pastie token (possibly due to a previous failure)");