| 28 | }; |
| 29 | |
| 30 | TEST_F(GPWriterTest, ConstructKeyName) { |
| 31 | string url = "https://s3-us-west-2.amazonaws.com/s3test.pivotal.io/dataset1/normal"; |
| 32 | |
| 33 | S3Params p = InitConfig(url + " config=data/s3test.conf"); |
| 34 | p.setAutoCompress(false); |
| 35 | |
| 36 | MockS3RESTfulService mockRESTfulService(p); |
| 37 | MockGPWriter gpwriter(p, &mockRESTfulService); |
| 38 | EXPECT_CALL(mockRESTfulService, head(_, _)).WillOnce(Return(404)); |
| 39 | |
| 40 | uint8_t xml[] = |
| 41 | "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" |
| 42 | "<InitiateMultipartUploadResult" |
| 43 | " xmlns=\"http://s3.amazonaws.com/doc/2006-03-01/\">" |
| 44 | "<Bucket>example-bucket</Bucket>" |
| 45 | "<Key>example-object</Key>" |
| 46 | "<UploadId>VXBsb2FkIElEIGZvciA2aWWpbmcncyBteS1tb3ZpZS5tMnRzIHVwbG9hZA</UploadId>" |
| 47 | "</InitiateMultipartUploadResult>"; |
| 48 | vector<uint8_t> raw(xml, xml + sizeof(xml) - 1); |
| 49 | Response response(RESPONSE_OK, raw); |
| 50 | |
| 51 | EXPECT_CALL(mockRESTfulService, post(_, _, vector<uint8_t>())).WillOnce(Return(response)); |
| 52 | |
| 53 | gpwriter.open(p); |
| 54 | |
| 55 | // "0"+".data"'s length is 6 |
| 56 | EXPECT_EQ((uint64_t)8, gpwriter.getKeyUrlToUpload().length() - url.length() - 6); |
| 57 | } |
| 58 | |
| 59 | TEST_F(GPWriterTest, GenerateUniqueKeyName) { |
| 60 | string url = "https://s3-us-west-2.amazonaws.com/s3test.pivotal.io/dataset1/normal"; |
nothing calls this directly
no test coverage detected