aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/actors/core/mon_ut.cpp
blob: fa5dbbe71eef40706cc68029d42e0006cc58a16a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <library/cpp/testing/unittest/registar.h>
#include <library/cpp/actors/core/mon.h>

using namespace NActors;
using namespace NMon;

Y_UNIT_TEST_SUITE(ActorSystemMon) {
    Y_UNIT_TEST(SerializeEv) {
        NActorsProto::TRemoteHttpInfo info;
        info.SetPath("hello");

        auto ev = std::make_unique<TEvRemoteHttpInfo>(info);
        UNIT_ASSERT(ev->ExtendedQuery);
        UNIT_ASSERT_VALUES_EQUAL(ev->ExtendedQuery->GetPath(), info.GetPath());
        UNIT_ASSERT_VALUES_EQUAL(ev->PathInfo(), info.GetPath());

        TAllocChunkSerializer ser;
        const bool success = ev->SerializeToArcadiaStream(&ser);
        Y_ABORT_UNLESS(success);
        auto buffer = ser.Release(ev->CreateSerializationInfo());
        std::unique_ptr<TEvRemoteHttpInfo> restored(dynamic_cast<TEvRemoteHttpInfo*>(TEvRemoteHttpInfo::Load(buffer.Get())));
        UNIT_ASSERT(restored->Query == ev->Query);
        UNIT_ASSERT(restored->Query.size());
        UNIT_ASSERT(restored->Query[0] == '\0');
        UNIT_ASSERT(restored->ExtendedQuery);
        UNIT_ASSERT_VALUES_EQUAL(restored->ExtendedQuery->GetPath(), ev->ExtendedQuery->GetPath());
        UNIT_ASSERT_VALUES_EQUAL(restored->PathInfo(), ev->PathInfo());
    }
}