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

Method SetupSuite

imagedata/image_data_test.go:34–72  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

32}
33
34func (s *ImageDataTestSuite) SetupSuite() {
35 s.data = testutil.NewTestDataProvider(s.T).Read("test1.jpg")
36
37 s.fetcherCfg, _ = testutil.NewLazySuiteObj(
38 s,
39 func() (*fetcher.Config, error) {
40 c := fetcher.NewDefaultConfig()
41 c.Transport.HTTP.AllowLoopbackSourceAddresses = true
42 c.Transport.HTTP.ClientKeepAliveTimeout = 0
43
44 return &c, nil
45 },
46 )
47
48 s.factory, _ = testutil.NewLazySuiteObj(
49 s,
50 func() (*imagedata.Factory, error) {
51 f, err := fetcher.New(s.fetcherCfg())
52 if err != nil {
53 return nil, err
54 }
55
56 return imagedata.NewFactory(f, nil), nil
57 },
58 )
59
60 s.testServer, _ = testutil.NewLazySuiteTestServer(
61 s,
62 func(srv *testutil.TestServer) error {
63 // Default headers and body for 200 OK response
64 srv.SetHeaders(
65 httpheaders.ContentType, "image/jpeg",
66 httpheaders.ContentLength, strconv.Itoa(len(s.data)),
67 ).SetBody(s.data)
68
69 return nil
70 },
71 )
72}
73
74func (s *ImageDataTestSuite) SetupSubTest() {
75 // We use t.Run() a lot, so we need to reset lazy objects at the beginning of each subtest

Callers

nothing calls this directly

Calls 9

NewTestDataProviderFunction · 0.92
NewLazySuiteObjFunction · 0.92
NewDefaultConfigFunction · 0.92
NewFunction · 0.92
NewFactoryFunction · 0.92
NewLazySuiteTestServerFunction · 0.92
SetBodyMethod · 0.80
SetHeadersMethod · 0.80
ReadMethod · 0.45

Tested by

no test coverage detected