|
|
@@ -223,7 +223,6 @@ TEST_F(JsonLayoutHeaderTest, ProvidesArrayBounds) {
|
|
|
}
|
|
|
|
|
|
TEST_F(JsonLayoutHeaderTest, SeparatesLogsWithComma) {
|
|
|
- using testing::Eq;
|
|
|
using testing::EndsWith;
|
|
|
using testing::StartsWith;
|
|
|
manager mgr;
|
|
|
@@ -236,3 +235,40 @@ TEST_F(JsonLayoutHeaderTest, SeparatesLogsWithComma) {
|
|
|
// So the dividing comma gets attached to the next log
|
|
|
EXPECT_THAT(appender->sstream.str(), StartsWith(",{"));
|
|
|
}
|
|
|
+
|
|
|
+struct JsonLayoutIncompleteTest : public JsonLayoutHeaderTest {
|
|
|
+ properties OVERRIDE{_obj({
|
|
|
+ {"configuration", _obj({
|
|
|
+ {"appenders", _obj({
|
|
|
+ {"Stub", _obj({
|
|
|
+ {"JsonLayout", _obj({
|
|
|
+ {"complete", _v(false)}
|
|
|
+ })}
|
|
|
+ })}
|
|
|
+ })}
|
|
|
+ })}
|
|
|
+ })};
|
|
|
+};
|
|
|
+
|
|
|
+TEST_F(JsonLayoutIncompleteTest, NoLogsMeansNoOutput) {
|
|
|
+ {
|
|
|
+ manager mgr;
|
|
|
+ mgr.configure(JSON_HEADER_SCHEMA.mergedWith(OVERRIDE));
|
|
|
+ }
|
|
|
+ using testing::Eq;
|
|
|
+ EXPECT_THAT(appender->sstream.str(), Eq(""));
|
|
|
+}
|
|
|
+
|
|
|
+TEST_F(JsonLayoutIncompleteTest, NonCompleteLogProducesJsonPerLine) {
|
|
|
+ using testing::EndsWith;
|
|
|
+ using testing::StartsWith;
|
|
|
+ manager mgr;
|
|
|
+ mgr.configure(JSON_HEADER_SCHEMA.mergedWith(OVERRIDE));
|
|
|
+ mgr.get().log(level::error, "HELLO");
|
|
|
+ // Newline is printed as a part of the message...
|
|
|
+ EXPECT_THAT(appender->sstream.str(), EndsWith("}\n"));
|
|
|
+ appender->sstream.str("");
|
|
|
+ mgr.get().log(level::error, "HELLO");
|
|
|
+ // So the dividing comma gets attached to the next log
|
|
|
+ EXPECT_THAT(appender->sstream.str(), StartsWith("{"));
|
|
|
+}
|