forked from trpc-group/trpc-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgreeter_service_test.cc
49 lines (39 loc) · 1.3 KB
/
greeter_service_test.cc
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//
//
// Tencent is pleased to support the open source community by making tRPC available.
//
// Copyright (C) 2023 THL A29 Limited, a Tencent company.
// All rights reserved.
//
// If you have downloaded a copy of the tRPC source code from Tencent,
// please note that tRPC source code is licensed under the Apache 2.0 License,
// A copy of the Apache 2.0 License is included in this file.
//
//
#include "gtest/gtest.h"
#include "trpc/common/status.h"
#include "trpc/server/make_server_context.h"
#include "trpc/server/trpc_server.h"
#include "examples/helloworld/greeter_service.h"
#include "examples/helloworld/helloworld.trpc.pb.h"
namespace test {
namespace helloworld {
namespace testing {
::trpc::ServerContextPtr MakeServerContext() {
::trpc::ServerContextPtr ctx = ::trpc::MakeServerContext();
// ...
return ctx;
}
TEST(GreeterServiceTest, SayHelloOK) {
auto server_context = MakeServerContext();
::trpc::test::helloworld::HelloRequest request;
request.set_msg("tRPC");
::trpc::test::helloworld::HelloReply response;
test::helloworld::GreeterServiceImpl svc_impl;
::trpc::Status status = svc_impl.SayHello(server_context, &request, &response);
ASSERT_TRUE(status.OK());
ASSERT_EQ(response.msg(), "Hello, tRPC");
}
} // namespace testing
} // namespace helloworld
} // namespace test