Skip to content

Commit fcea312

Browse files
committed
Try to fix Unit tests
1 parent a2e2225 commit fcea312

1 file changed

Lines changed: 15 additions & 10 deletions

File tree

tests/unit/sources/server/startupOptions/TestLoader.cpp

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ class CTestPath final
3232
test_common::Filesystem::createDirectory(m_testDirectory);
3333
}
3434

35+
std::filesystem::path dir() const
36+
{
37+
return m_testDirectory;
38+
}
39+
3540
~CTestPath()
3641
{
3742
// Clean-up TestDirectory
@@ -49,7 +54,7 @@ class CTestPath final
4954
}
5055

5156
private:
52-
const std::filesystem::path m_testDirectory;
57+
std::filesystem::path m_testDirectory;
5358
};
5459

5560
static const std::string TestNewWebServerPath("newNewWebServerPath");
@@ -655,7 +660,7 @@ BOOST_AUTO_TEST_SUITE(TestLoader)
655660
{
656661
CTestPath webServerPath(TestNewWebServerPath);
657662
std::string arg = "-w";
658-
arg += TestNewWebServerPath;
663+
arg += webServerPath.dir().string();
659664

660665
const char* argv[] = {"./TestLoader", const_cast<char*>(arg.c_str())};
661666

@@ -664,7 +669,7 @@ BOOST_AUTO_TEST_SUITE(TestLoader)
664669
BOOST_CHECK_EQUAL(loader.options().getLogLevel(), "information") ;
665670
BOOST_CHECK_EQUAL(loader.options().getWebServerPortNumber(), static_cast<unsigned int>(8080)) ;
666671
BOOST_CHECK_EQUAL(loader.options().getWebServerIPAddress(), "0.0.0.0") ;
667-
BOOST_CHECK_EQUAL(loader.options().getWebServerInitialPath(), TestNewWebServerPath) ;
672+
BOOST_CHECK_EQUAL(loader.options().getWebServerInitialPath(), webServerPath.dir()) ;
668673
BOOST_CHECK_EQUAL(loader.options().getDatabaseSqliteFile(), "yadoms.db3") ;
669674
BOOST_CHECK_EQUAL(loader.options().getPluginsPath(), "plugins") ;
670675
BOOST_CHECK_EQUAL(loader.options().getScriptInterpretersPath(), "scriptInterpreters") ;
@@ -684,15 +689,15 @@ BOOST_AUTO_TEST_SUITE(TestLoader)
684689
{
685690
CTestPath webServerPath(TestNewWebServerPath);
686691
std::string arg = "--webServerPath:";
687-
arg += TestNewWebServerPath;
692+
arg += webServerPath.dir().string();
688693
const char* argv[] = {"./TestLoader", const_cast<char*>(arg.c_str())};
689694

690695
CStartupOptionMockup loader(2, argv, true);
691696

692697
BOOST_CHECK_EQUAL(loader.options().getLogLevel(), "information") ;
693698
BOOST_CHECK_EQUAL(loader.options().getWebServerPortNumber(), static_cast<unsigned int>(8080)) ;
694699
BOOST_CHECK_EQUAL(loader.options().getWebServerIPAddress(), "0.0.0.0") ;
695-
BOOST_CHECK_EQUAL(loader.options().getWebServerInitialPath(), TestNewWebServerPath) ;
700+
BOOST_CHECK_EQUAL(loader.options().getWebServerInitialPath(), webServerPath.dir()) ;
696701
BOOST_CHECK_EQUAL(loader.options().getDatabaseSqliteFile(), "yadoms.db3") ;
697702
BOOST_CHECK_EQUAL(loader.options().getPluginsPath(), "plugins") ;
698703
BOOST_CHECK_EQUAL(loader.options().getScriptInterpretersPath(), "scriptInterpreters") ;
@@ -727,15 +732,15 @@ BOOST_AUTO_TEST_SUITE(TestLoader)
727732

728733
BOOST_AUTO_TEST_CASE(All_Options1)
729734
{
730-
CTestPath webServerPath(TestNewWebServerPath);
735+
const auto wewWebServerPath = CTestPath(TestNewWebServerPath).dir().string();
731736

732737
const char* argv[] =
733738
{
734739
"./TestLoader",
735740
"--port", "8085",
736741
"--databaseSqliteFile", "test.db3",
737742
"--webServerIp", "192.168.1.3",
738-
"--webServerPath", const_cast<char*>(TestNewWebServerPath.c_str()),
743+
"--webServerPath", wewWebServerPath.c_str(),
739744
"--logLevel", "warning"
740745
};
741746

@@ -744,7 +749,7 @@ BOOST_AUTO_TEST_SUITE(TestLoader)
744749
BOOST_CHECK_EQUAL(loader.options().getLogLevel(), "warning") ;
745750
BOOST_CHECK_EQUAL(loader.options().getWebServerPortNumber(), static_cast<unsigned int>(8085)) ;
746751
BOOST_CHECK_EQUAL(loader.options().getWebServerIPAddress(), "192.168.1.3") ;
747-
BOOST_CHECK_EQUAL(loader.options().getWebServerInitialPath(), TestNewWebServerPath) ;
752+
BOOST_CHECK_EQUAL(loader.options().getWebServerInitialPath(), wewWebServerPath) ;
748753
BOOST_CHECK_EQUAL(loader.options().getDatabaseSqliteFile(), "test.db3") ;
749754
BOOST_CHECK_EQUAL(loader.options().getPluginsPath(), "plugins") ;
750755
BOOST_CHECK_EQUAL(loader.options().getScriptInterpretersPath(), "scriptInterpreters") ;
@@ -765,7 +770,7 @@ BOOST_AUTO_TEST_SUITE(TestLoader)
765770
CTestPath webServerPath(TestNewWebServerPath);
766771

767772
std::string arg = "-w:";
768-
arg += TestNewWebServerPath;
773+
arg += webServerPath.dir().string();
769774

770775
const char* argv[] =
771776
{
@@ -782,7 +787,7 @@ BOOST_AUTO_TEST_SUITE(TestLoader)
782787
BOOST_CHECK_EQUAL(loader.options().getLogLevel(), "warning") ;
783788
BOOST_CHECK_EQUAL(loader.options().getWebServerPortNumber(), static_cast<unsigned int>(8085)) ;
784789
BOOST_CHECK_EQUAL(loader.options().getWebServerIPAddress(), "192.168.1.3") ;
785-
BOOST_CHECK_EQUAL(loader.options().getWebServerInitialPath(), TestNewWebServerPath) ;
790+
BOOST_CHECK_EQUAL(loader.options().getWebServerInitialPath(), webServerPath.dir()) ;
786791
BOOST_CHECK_EQUAL(loader.options().getDatabaseSqliteFile(), "test.db3") ;
787792
BOOST_CHECK_EQUAL(loader.options().getPluginsPath(), "plugins") ;
788793
BOOST_CHECK_EQUAL(loader.options().getScriptInterpretersPath(), "scriptInterpreters") ;

0 commit comments

Comments
 (0)