| 261 | }; |
| 262 | |
| 263 | TEST(CurlHttpRequestTest, GetRequest) { |
| 264 | FakeLibCurl libcurl("get response", 200); |
| 265 | CurlHttpRequest http_request(&libcurl); |
| 266 | |
| 267 | std::vector<char> scratch; |
| 268 | scratch.insert(scratch.begin(), kTestContent.begin(), kTestContent.end()); |
| 269 | scratch.reserve(100); |
| 270 | |
| 271 | http_request.SetUri("http://www.testuri.com"); |
| 272 | http_request.AddAuthBearerHeader("fake-bearer"); |
| 273 | http_request.SetRange(100, 199); |
| 274 | http_request.SetResultBuffer(&scratch); |
| 275 | TF_EXPECT_OK(http_request.Send()); |
| 276 | |
| 277 | EXPECT_EQ("get response", string(scratch.begin(), scratch.end())); |
| 278 | |
| 279 | // Check interactions with libcurl. |
| 280 | EXPECT_TRUE(libcurl.is_initialized_); |
| 281 | EXPECT_EQ("http://www.testuri.com", libcurl.url_); |
| 282 | EXPECT_EQ("100-199", libcurl.range_); |
| 283 | EXPECT_EQ("", libcurl.custom_request_); |
| 284 | EXPECT_EQ(1, libcurl.headers_->size()); |
| 285 | EXPECT_EQ("Authorization: Bearer fake-bearer", (*libcurl.headers_)[0]); |
| 286 | EXPECT_FALSE(libcurl.is_post_); |
| 287 | EXPECT_EQ(200, http_request.GetResponseCode()); |
| 288 | } |
| 289 | |
| 290 | TEST(CurlHttpRequestTest, GetRequest_Direct) { |
| 291 | FakeLibCurl libcurl("get response", 200); |
nothing calls this directly
no test coverage detected