Debian Codegraph @

test/core/client_channel/client_channel_test.cc

raw
1 //
2 // Copyright 2022 gRPC authors.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 #include <grpc/support/port_platform.h>
18
19 #include "src/core/ext/filters/client_channel/client_channel.h"
20
21 #include "gtest/gtest.h"
22
23 #include <grpc/grpc.h>
24
25 #include "src/core/ext/filters/client_channel/subchannel_pool_interface.h"
26 #include "src/core/lib/channel/channel_args.h"
27 #include "test/core/util/test_config.h"
28
29 namespace grpc_core {
30 namespace testing {
31 namespace {
32
33 TEST(MakeSubchannelArgs, UsesChannelDefaultAuthorityByDefault) {
34 ChannelArgs args = ClientChannel::MakeSubchannelArgs(
35 ChannelArgs(), ChannelArgs(), nullptr, "foo.example.com");
36 EXPECT_EQ(args.GetString(GRPC_ARG_DEFAULT_AUTHORITY), "foo.example.com");
37 }
38
39 TEST(MakeSubchannelArgs, DefaultAuthorityFromChannelArgs) {
40 ChannelArgs args = ClientChannel::MakeSubchannelArgs(
41 ChannelArgs().Set(GRPC_ARG_DEFAULT_AUTHORITY, "bar.example.com"),
42 ChannelArgs(), nullptr, "foo.example.com");
43 EXPECT_EQ(args.GetString(GRPC_ARG_DEFAULT_AUTHORITY), "bar.example.com");
44 }
45
46 TEST(MakeSubchannelArgs, DefaultAuthorityFromResolver) {
47 ChannelArgs args = ClientChannel::MakeSubchannelArgs(
48 ChannelArgs(),
49 ChannelArgs().Set(GRPC_ARG_DEFAULT_AUTHORITY, "bar.example.com"), nullptr,
50 "foo.example.com");
51 EXPECT_EQ(args.GetString(GRPC_ARG_DEFAULT_AUTHORITY), "bar.example.com");
52 }
53
54 TEST(MakeSubchannelArgs,
55 DefaultAuthorityFromChannelArgsOverridesValueFromResolver) {
56 ChannelArgs args = ClientChannel::MakeSubchannelArgs(
57 ChannelArgs().Set(GRPC_ARG_DEFAULT_AUTHORITY, "bar.example.com"),
58 ChannelArgs().Set(GRPC_ARG_DEFAULT_AUTHORITY, "baz.example.com"), nullptr,
59 "foo.example.com");
60 EXPECT_EQ(args.GetString(GRPC_ARG_DEFAULT_AUTHORITY), "bar.example.com");
61 }
62
63 } // namespace
64 } // namespace testing
65 } // namespace grpc_core
66
67 int main(int argc, char** argv) {
68 ::testing::InitGoogleTest(&argc, argv);
69 grpc::testing::TestEnvironment env(&argc, argv);
70 auto result = RUN_ALL_TESTS();
71 return result;
72 }