gpAux/extensions/gps3ext/test/s3common_writer_test.cpp
// We need to mock uploadPartOfData() and completeMultiPart() in GZip mode,
// because even an empty string will produce 20+ bytes for GZip header and trailer,
// and then in open() may flush those data into S3KeyWriter.
We need to mock uploadPartOfData() and completeMultiPart() in GZip mode,
because even an empty string will produce 20+ bytes for GZip header and trailer,
and then in open() may flush those data into S3KeyWriter.
We need to mock uploadPartOfData () and completeMultiPart () in GZip mode because even an empty string will produce 20 + bytes for GZip header and trailer and then in open () may flush those data into S3KeyWriter .
TEST_F(S3CommonWriteTest, UsingGZip) {
    s3ext_autocompress = true;
    EXPECT_CALL(mockS3Interface, getUploadId(_, _, _))
        .WillOnce(Invoke(&mockS3Interface, &MockS3InterfaceForCompressionWrite::mockGetUploadId));
    EXPECT_CALL(mockS3Interface, uploadPartOfData(_, _, _, _, _, _))
        .WillOnce(
            Invoke(&mockS3Interface, &MockS3InterfaceForCompressionWrite::mockUploadPartOfData));
    EXPECT_CALL(mockS3Interface, completeMultiPart(_, _, _, _, _))
        .WillOnce(
            Invoke(&mockS3Interface, &MockS3InterfaceForCompressionWrite::mockCompleteMultiPart));
    WriterParams params;
    params.setNumOfChunks(1);
    params.setChunkSize(S3_ZIP_COMPRESS_CHUNKSIZE + 1);
    this->open(params);
    ASSERT_EQ(this->upstreamWriter, &this->compressWriter);
    ASSERT_TRUE(NULL != dynamic_cast<CompressWriter*>(this->upstreamWriter));
}
TEST_F ( S3CommonWriteTest , UsingGZip ) { s3ext_autocompress = true ; EXPECT_CALL ( mockS3Interface , getUploadId ( _ , _ , _ ) ) . WillOnce ( Invoke ( & mockS3Interface , & MockS3InterfaceForCompressionWrite :: mockGetUploadId ) ) ; EXPECT_CALL ( mockS3Interface , uploadPartOfData ( _ , _ , _ , _ , _ , _ ) ) . WillOnce ( Invoke ( & mockS3Interface , & MockS3InterfaceForCompressionWrite :: mockUploadPartOfData ) ) ; EXPECT_CALL ( mockS3Interface , completeMultiPart ( _ , _ , _ , _ , _ ) ) . WillOnce ( Invoke ( & mockS3Interface , & MockS3InterfaceForCompressionWrite :: mockCompleteMultiPart ) ) ; WriterParams params ; params . setNumOfChunks ( 1 ) ; params . setChunkSize ( S3_ZIP_COMPRESS_CHUNKSIZE + 1 ) ; this -> open ( params ) ; ASSERT_EQ ( this -> upstreamWriter , & this -> compressWriter ) ; ASSERT_TRUE ( NULL != dynamic_cast < CompressWriter * > ( this -> upstreamWriter ) ) ; }
We need to mock uploadPartOfData() and completeMultiPart() in GZip mode,
because even an empty string will produce 20+ bytes for GZip header and trailer,
and then in open() may flush those data into S3KeyWriter.
We need to mock uploadPartOfData () and completeMultiPart () in GZip mode because even an empty string will produce 20 + bytes for GZip header and trailer and then in open () may flush those data into S3KeyWriter .