MCPcopy Create free account
hub / github.com/imgproxy/imgproxy / TestDownloadGzip

Method TestDownloadGzip

imagedata/image_data_test.go:262–286  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

260}
261
262func (s *ImageDataTestSuite) TestDownloadGzip() {
263 buf := new(bytes.Buffer)
264
265 enc := gzip.NewWriter(buf)
266 _, err := enc.Write(s.data)
267 s.Require().NoError(err)
268 err = enc.Close()
269 s.Require().NoError(err)
270
271 s.testServer().
272 SetBody(buf.Bytes()).
273 SetHeaders(
274 httpheaders.ContentEncoding, "gzip",
275 httpheaders.ContentLength, strconv.Itoa(buf.Len()), // Update Content-Length
276 )
277
278 imgdata, _, err := s.factory().DownloadSync(
279 context.Background(), s.testServer().URL(), "Test image", imagedata.DownloadOptions{},
280 )
281
282 s.Require().NoError(err)
283 s.Require().NotNil(imgdata)
284 s.Require().True(testutil.ReadersEqual(s.T(), bytes.NewReader(s.data), imgdata.Reader()))
285 s.Require().Equal(imagetype.JPEG, imgdata.Format())
286}
287
288func (s *ImageDataTestSuite) TestFromFile() {
289 imgdata, err := s.factory().NewFromPath("../testdata/test1.jpg")

Callers

nothing calls this directly

Calls 14

WriteMethod · 0.95
ReadersEqualFunction · 0.92
NewWriterMethod · 0.80
SetHeadersMethod · 0.80
SetBodyMethod · 0.80
BytesMethod · 0.80
DownloadSyncMethod · 0.80
BackgroundMethod · 0.80
TMethod · 0.80
CloseMethod · 0.65
ReaderMethod · 0.65
FormatMethod · 0.65

Tested by

no test coverage detected