Full C++23 framework tree: runtime, observability, security, data, app, realtime, supervisor, clients, CLI, example plus enterprise tenancy, audit, operability, governance, supplychain. Postgres via docker compose for tests.
50 lines
1.2 KiB
C++
50 lines
1.2 KiB
C++
#pragma once
|
|
|
|
// Shared test support for the living example suite. Not a test itself: every
|
|
// test file owns one main() and uses these helpers for loud assertions.
|
|
|
|
#include <iostream>
|
|
#include <string>
|
|
|
|
#include "app/App.hpp"
|
|
#include "fw/TestClient.hpp"
|
|
|
|
namespace molo::example::test {
|
|
|
|
inline int g_failures = 0;
|
|
|
|
inline void check(bool cond, const std::string& what) {
|
|
if (cond) {
|
|
std::cout << " ok: " << what << "\n";
|
|
} else {
|
|
++g_failures;
|
|
std::cout << " FAIL: " << what << "\n";
|
|
}
|
|
}
|
|
|
|
inline bool contains(const std::string& hay, const std::string& needle) {
|
|
return hay.find(needle) != std::string::npos;
|
|
}
|
|
|
|
inline int finish(const std::string& name) {
|
|
if (g_failures == 0) {
|
|
std::cout << "PASS: " << name << "\n";
|
|
return 0;
|
|
}
|
|
std::cout << "FAIL: " << name << " (" << g_failures << " failures)\n";
|
|
return 1;
|
|
}
|
|
|
|
struct Fixture {
|
|
molo::example::app::Services services;
|
|
std::shared_ptr<molo::example::fw::Application> app;
|
|
std::shared_ptr<molo::example::fw::TestClient> client;
|
|
|
|
Fixture() {
|
|
app = molo::example::app::build_application(services);
|
|
client = std::make_shared<molo::example::fw::TestClient>(app);
|
|
}
|
|
};
|
|
|
|
} // namespace molo::example::test
|