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

Method TestDownloadUnreachable

imagedata/image_data_test.go:211–223  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

209}
210
211func (s *ImageDataTestSuite) TestDownloadUnreachable() {
212 l, err := net.Listen("tcp", "127.0.0.1:0")
213 s.Require().NoError(err)
214 l.Close()
215
216 serverURL := fmt.Sprintf("http://%s", l.Addr().String())
217
218 imgdata, _, err := s.factory().DownloadSync(context.Background(), serverURL, "Test image", imagedata.DownloadOptions{})
219
220 s.Require().Error(err)
221 s.Require().Equal(404, errctx.Wrap(err).StatusCode())
222 s.Require().Nil(imgdata)
223}
224
225func (s *ImageDataTestSuite) TestDownloadInvalidImage() {
226 s.testServer().SetBody([]byte("invalid"))

Callers

nothing calls this directly

Calls 7

WrapFunction · 0.92
DownloadSyncMethod · 0.80
BackgroundMethod · 0.80
CloseMethod · 0.65
ErrorMethod · 0.65
StatusCodeMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected