@@ -279,83 +279,3 @@ void Postfix::configureRelay(const std::filesystem::path& basedir)
279279
280280 ini.saveFile (mainFile);
281281}
282-
283- #ifdef BUILD_TESTING
284- #include < doctest/doctest.h>
285- #else
286- #define DOCTEST_CONFIG_DISABLE
287- #include < doctest/doctest.h>
288- #endif
289-
290- #include < cloysterhpc/tempdir.h>
291- #include < cloysterhpc/tests.h>
292- #include < testing/test_message_bus.h>
293-
294- #ifdef BUILD_TESTING
295-
296- TEST_SUITE (" Test repository file read and write" )
297- {
298- TEST_CASE (
299- " Test if we comment the local config correctly if not on local profile" )
300- {
301- std::string isLocal
302- = " local unix - n n - - local" ;
303- std::string notLocal = " notlocal unix - n n - "
304- " - nlocal" ;
305-
306- maybeDisableLocalOnMasterFile (isLocal);
307- maybeDisableLocalOnMasterFile (notLocal);
308-
309- CHECK (isLocal
310- == " #local unix - n n - - "
311- " local" );
312- CHECK (notLocal
313- == " notlocal unix - n n - - "
314- " nlocal" );
315- }
316-
317- TEST_CASE (" Test if Postfix files generate correctly in the Local profile" )
318- {
319- auto testbus = std::make_shared<TestMessageBus>();
320-
321- std::vector<sdbus::Struct<std::string, std::string, std::string>> rete
322- = { std::make_tuple (" postfix.service" , " " , " " ) };
323- std::vector<sdbus::Struct<std::string, std::string, std::string>> retd
324- = { std::make_tuple (" postfix.service" , " " , " " ) };
325-
326- testbus->registerResponse (
327- std::make_tuple<std::string, std::string>(
328- " org.freedesktop.systemd1.Manager" , " EnableUnitFiles" ),
329- std::make_tuple<bool , decltype (rete)>(true , std::move (rete)));
330- testbus->registerResponse (
331- std::make_tuple<std::string, std::string>(
332- " org.freedesktop.systemd1.Manager" , " DisableUnitFiles" ),
333- retd);
334-
335- MockRunner mr;
336- Postfix pfix { testbus, mr, Postfix::Profile::Local };
337- TempDir d;
338-
339- cloyster::touchFile (d.name () / " main.cf" );
340- std::ofstream o { d.name () / " master.cf" };
341- const auto & content {
342- #include " cloysterhpc/tmpl/postfix/master.cf.tmpl"
343- };
344- o << content;
345- o.close ();
346-
347- pfix.setup (d.name ());
348-
349- CHECK (std::filesystem::file_size (d.name () / " main.cf" ) > 10 );
350- CHECK (std::filesystem::file_size (d.name () / " master.cf" ) > 10 );
351-
352- CHECK (testbus->callCount (std::make_tuple (
353- " org.freedesktop.systemd1.Manager" , " EnableUnitFiles" ))
354- == 1 );
355- CHECK (testbus->callCount (std::make_tuple (
356- " org.freedesktop.systemd1.Manager" , " StartUnit" ))
357- == 1 );
358- }
359- }
360-
361- #endif
0 commit comments