@@ -190,13 +190,16 @@ TEST(GrpcObjectReadSource, UseSpillBufferMany) {
190190
191191TEST (GrpcObjectReadSource, PreserveChecksums) {
192192 auto mock = absl::make_unique<MockStream>();
193- std::string const expected_md5 = " 9e107d9d372bb6826bd81d3542a419d6" ;
194- std::string const expected_crc32c = " ImIEBA==" ;
193+ std::string const expected_payload =
194+ " The quick brown fox jumps over the lazy dog" ;
195+ auto const expected_md5 = ComputeMD5Hash (expected_payload);
196+ auto const expected_crc32c = ComputeCrc32cChecksum (expected_payload);
195197 EXPECT_CALL (*mock, Read)
196198 .WillOnce ([&]() {
197199 storage_proto::GetObjectMediaResponse response;
198200 response.mutable_checksummed_data ()->set_content (" The quick brown" );
199- response.mutable_object_checksums ()->set_md5_hash (expected_md5);
201+ response.mutable_object_checksums ()->set_md5_hash (
202+ GrpcClient::MD5ToProto (expected_md5));
200203 response.mutable_object_checksums ()->mutable_crc32c ()->set_value (
201204 GrpcClient::Crc32cToProto (expected_crc32c));
202205 return response;
@@ -207,21 +210,21 @@ TEST(GrpcObjectReadSource, PreserveChecksums) {
207210 " fox jumps over the lazy dog" );
208211 // The headers may be included more than once in the stream,
209212 // `GrpcObjectReadSource` should return them only once.
210- response.mutable_object_checksums ()->set_md5_hash (expected_md5);
213+ response.mutable_object_checksums ()->set_md5_hash (
214+ GrpcClient::MD5ToProto (expected_md5));
211215 response.mutable_object_checksums ()->mutable_crc32c ()->set_value (
212216 GrpcClient::Crc32cToProto (expected_crc32c));
213217 return response;
214218 })
215219 .WillOnce (Return (Status{}));
216220 GrpcObjectReadSource tested (std::move (mock));
217- std::string const expected = " The quick brown fox jumps over the lazy dog" ;
218221 std::vector<char > buffer (1024 );
219222 auto response = tested.Read (buffer.data (), buffer.size ());
220223 ASSERT_STATUS_OK (response);
221- EXPECT_EQ (expected .size (), response->bytes_received );
224+ EXPECT_EQ (expected_payload .size (), response->bytes_received );
222225 EXPECT_EQ (100 , response->response .status_code );
223- std::string actual (buffer.data (), expected. size () );
224- EXPECT_EQ (expected , actual);
226+ auto const actual = std::string (buffer.data (), response-> bytes_received );
227+ EXPECT_EQ (expected_payload , actual);
225228 auto const & headers = response->response .headers ;
226229 EXPECT_FALSE (headers.find (" x-goog-hash" ) == headers.end ());
227230 auto const values = [&headers] {
@@ -232,9 +235,8 @@ TEST(GrpcObjectReadSource, PreserveChecksums) {
232235 }
233236 return v;
234237 }();
235- EXPECT_THAT (values, UnorderedElementsAre (
236- " crc32c=" + expected_crc32c,
237- " md5=" + GrpcClient::MD5FromProto (expected_md5)));
238+ EXPECT_THAT (values, UnorderedElementsAre (" crc32c=" + expected_crc32c,
239+ " md5=" + expected_md5));
238240
239241 auto status = tested.Close ();
240242 EXPECT_STATUS_OK (status);
0 commit comments