#ifndef MOCKDEFS_H #define MOCKDEFS_H #include <pq-mock.h> #include <visibility.h> #include <dryice.h> #include <portage.h> #include <users.h> #include <maintenance.h> #include <notifications.h> #include <selectcommandUtil.impl.h> #include <boost/test/unit_test.hpp> class DLL_PUBLIC Service : public IceTray::DryIce, DB::PluginMock<PQ::Mock> { public: Service(); }; class DLL_PUBLIC Maintenance : public IceTray::DryIce, DB::PluginMock<PQ::Mock> { public: Maintenance(); }; class DLL_PUBLIC Mail : public IceTray::DryIce { public: Mail(); }; class DLL_PUBLIC TestClient : public IceTray::DryIceClient { public: TestClient(); Gentoo::MaintenancePrxPtr m; Gentoo::PortagePrxPtr p; Gentoo::NotificationsPtr n; IceTray::Mail::MailServerPtr ms; Gentoo::UsersPrxPtr u; void lintable_test_files(std::string_view name, IceTray::Mail::EmailPtr e); }; #define SQL_REQUIRE_EQUAL(sql, type, expected) BOOST_TEST_CONTEXT(sql) { sqlRequireEqual<type>(db, sql, expected); } template<typename T> void sqlRequireEqual(DB::ConnectionPtr db, const char * const sql, const T & expected) { int assertedRows = 0; db->select(sql)->forEachRow<T>([expected,&assertedRows](const auto & n) { BOOST_REQUIRE_EQUAL(expected, n); assertedRows += 1; }); BOOST_REQUIRE_EQUAL(assertedRows, 1); } #endif