summaryrefslogtreecommitdiffstats
path: root/library/cpp/yt/logging/unittests/structured_payload_ut.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'library/cpp/yt/logging/unittests/structured_payload_ut.cpp')
-rw-r--r--library/cpp/yt/logging/unittests/structured_payload_ut.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/library/cpp/yt/logging/unittests/structured_payload_ut.cpp b/library/cpp/yt/logging/unittests/structured_payload_ut.cpp
new file mode 100644
index 00000000000..f15970dcb23
--- /dev/null
+++ b/library/cpp/yt/logging/unittests/structured_payload_ut.cpp
@@ -0,0 +1,36 @@
+#include <library/cpp/testing/gtest/gtest.h>
+
+#include <library/cpp/yt/logging/structured_payload.h>
+
+#include <library/cpp/yt/yson_string/string.h>
+
+namespace NYT::NLogging {
+namespace {
+
+using namespace NYson;
+
+////////////////////////////////////////////////////////////////////////////////
+
+TYsonString MakeMapFragment(TStringBuf yson)
+{
+ return TYsonString(yson, EYsonType::MapFragment);
+}
+
+TEST(TStructuredPayloadTest, RoundTrip)
+{
+ auto payload = MakeStructuredPayloadFromYson(MakeMapFragment("\"key\"=\"value\""));
+ auto view = GetYsonFromStructuredPayload(payload);
+ EXPECT_EQ(view.GetType(), EYsonType::MapFragment);
+ EXPECT_EQ(view.AsStringBuf(), "\"key\"=\"value\"");
+}
+
+TEST(TStructuredPayloadTest, EmptyFragment)
+{
+ auto payload = MakeStructuredPayloadFromYson(MakeMapFragment(""));
+ EXPECT_EQ(GetYsonFromStructuredPayload(payload).AsStringBuf(), "");
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+} // namespace
+} // namespace NYT::NLogging