blob: 59feedd5bb84cc9ca13370bf5f83c3d4492a51d4 [file] [log] [blame]
#include "remote_logging_tests.hpp"
#include <fstream>
namespace phosphor
{
namespace logging
{
namespace test
{
std::string getConfig(const char* filePath)
{
std::fstream stream(filePath, std::fstream::in);
std::string line;
getline(stream, line);
return line;
}
TEST_F(TestRemoteLogging, testOnlyAddress)
{
config->address("1.1.1.1");
EXPECT_EQ(getConfig(configFilePath.c_str()), "#*.* @@remote-host:port");
}
TEST_F(TestRemoteLogging, testOnlyPort)
{
config->port(100);
EXPECT_EQ(getConfig(configFilePath.c_str()), "#*.* @@remote-host:port");
}
TEST_F(TestRemoteLogging, testGoodConfig)
{
config->address("1.1.1.1");
config->port(100);
EXPECT_EQ(getConfig(configFilePath.c_str()), "*.* @@1.1.1.1:100");
}
TEST_F(TestRemoteLogging, testClearAddress)
{
config->address("1.1.1.1");
config->port(100);
EXPECT_EQ(getConfig(configFilePath.c_str()), "*.* @@1.1.1.1:100");
config->address("");
EXPECT_EQ(getConfig(configFilePath.c_str()), "#*.* @@remote-host:port");
}
TEST_F(TestRemoteLogging, testClearPort)
{
config->address("1.1.1.1");
config->port(100);
EXPECT_EQ(getConfig(configFilePath.c_str()), "*.* @@1.1.1.1:100");
config->port(0);
EXPECT_EQ(getConfig(configFilePath.c_str()), "#*.* @@remote-host:port");
}
} // namespace test
} // namespace logging
} // namespace phosphor