blob: 8c3a98a9bd1e49d3ada64fa43008cde1f3239f21 [file] [log] [blame]
Deepak Kodihalli5ac1bde2018-08-30 05:38:44 -05001#include "remote_logging_tests.hpp"
2#include <fstream>
3
4namespace phosphor
5{
6namespace logging
7{
8namespace test
9{
10
11std::string getConfig(const char* filePath)
12{
13 std::fstream stream(filePath, std::fstream::in);
14 std::string line;
15 getline(stream, line);
16 return line;
17}
18
19TEST_F(TestRemoteLogging, testOnlyAddress)
20{
21 config->address("1.1.1.1");
22 EXPECT_EQ(getConfig(configFilePath.c_str()), "#*.* @@remote-host:port");
23}
24
25TEST_F(TestRemoteLogging, testOnlyPort)
26{
27 config->port(100);
28 EXPECT_EQ(getConfig(configFilePath.c_str()), "#*.* @@remote-host:port");
29}
30
31TEST_F(TestRemoteLogging, testGoodConfig)
32{
33 config->address("1.1.1.1");
34 config->port(100);
35 EXPECT_EQ(getConfig(configFilePath.c_str()), "*.* @@1.1.1.1:100");
36}
37
38TEST_F(TestRemoteLogging, testClearAddress)
39{
40 config->address("1.1.1.1");
41 config->port(100);
42 EXPECT_EQ(getConfig(configFilePath.c_str()), "*.* @@1.1.1.1:100");
43 config->address("");
44 EXPECT_EQ(getConfig(configFilePath.c_str()), "#*.* @@remote-host:port");
45}
46
47TEST_F(TestRemoteLogging, testClearPort)
48{
49 config->address("1.1.1.1");
50 config->port(100);
51 EXPECT_EQ(getConfig(configFilePath.c_str()), "*.* @@1.1.1.1:100");
52 config->port(0);
53 EXPECT_EQ(getConfig(configFilePath.c_str()), "#*.* @@remote-host:port");
54}
55
56}// namespace test
57}// namespace logging
58}// namespace phosphor