MCPcopy Create free account
hub / github.com/apache/brpc / TEST_F

Function TEST_F

test/brpc_redis_unittest.cpp:158–235  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

156}
157
158TEST_F(RedisTest, sanity) {
159 if (g_redis_pid < 0) {
160 puts("Skipped due to absence of redis-server");
161 return;
162 }
163 brpc::ChannelOptions options;
164 options.protocol = brpc::PROTOCOL_REDIS;
165 brpc::Channel channel;
166 ASSERT_EQ(0, channel.Init("0.0.0.0:" REDIS_SERVER_PORT, &options));
167 brpc::RedisRequest request;
168 brpc::RedisResponse response;
169 brpc::Controller cntl;
170
171 ASSERT_TRUE(request.AddCommand("get hello"));
172 channel.CallMethod(NULL, &cntl, &request, &response, NULL);
173 ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
174 ASSERT_EQ(1, response.reply_size());
175 ASSERT_EQ(brpc::REDIS_REPLY_NIL, response.reply(0).type())
176 << response;
177
178 cntl.Reset();
179 request.Clear();
180 response.Clear();
181 request.AddCommand("set hello world");
182 channel.CallMethod(NULL, &cntl, &request, &response, NULL);
183 ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
184 ASSERT_EQ(1, response.reply_size());
185 ASSERT_EQ(brpc::REDIS_REPLY_STATUS, response.reply(0).type());
186 ASSERT_EQ("OK", response.reply(0).data());
187
188 cntl.Reset();
189 request.Clear();
190 response.Clear();
191 ASSERT_TRUE(request.AddCommand("get hello"));
192 channel.CallMethod(NULL, &cntl, &request, &response, NULL);
193 ASSERT_FALSE(cntl.Failed());
194 ASSERT_EQ(1, response.reply_size());
195 ASSERT_EQ(brpc::REDIS_REPLY_STRING, response.reply(0).type());
196 ASSERT_EQ("world", response.reply(0).data());
197
198 cntl.Reset();
199 request.Clear();
200 response.Clear();
201 request.AddCommand("set hello world2");
202 channel.CallMethod(NULL, &cntl, &request, &response, NULL);
203 ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
204 ASSERT_EQ(1, response.reply_size());
205 ASSERT_EQ(brpc::REDIS_REPLY_STATUS, response.reply(0).type());
206 ASSERT_EQ("OK", response.reply(0).data());
207
208 cntl.Reset();
209 request.Clear();
210 response.Clear();
211 ASSERT_TRUE(request.AddCommand("get hello"));
212 channel.CallMethod(NULL, &cntl, &request, &response, NULL);
213 ASSERT_FALSE(cntl.Failed());
214 ASSERT_EQ(1, response.reply_size());
215 ASSERT_EQ(brpc::REDIS_REPLY_STRING, response.reply(0).type());

Callers

nothing calls this directly

Calls 15

AssertResponseEqualFunction · 0.85
GeneratePasswordFunction · 0.85
RedisCommandNoFormatFunction · 0.85
GetCompleteCommandFunction · 0.85
fast_rand_less_thanFunction · 0.85
bthread_start_backgroundFunction · 0.85
bthread_joinFunction · 0.85
ErrorTextMethod · 0.80
reply_sizeMethod · 0.80
integerMethod · 0.80
okMethod · 0.80

Tested by

no test coverage detected