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

Function NewLazySuiteTestServer

testutil/test_server.go:28–55  ·  view source on GitHub ↗

NewLazySuiteTestServer creates a lazy TestServer object for use in test suites

(
	l LazySuiteFrom,
	init ...func(*TestServer) error,
)

Source from the content-addressed store, hash-verified

26
27// NewLazySuiteTestServer creates a lazy TestServer object for use in test suites
28func NewLazySuiteTestServer(
29 l LazySuiteFrom,
30 init ...func(*TestServer) error,
31) (LazyObj[*TestServer], context.CancelFunc) {
32 return NewLazySuiteObj(
33 l,
34 func() (*TestServer, error) {
35 s := NewTestServer()
36
37 if len(init) > 0 {
38 for _, fn := range init {
39 if fn == nil {
40 continue
41 }
42
43 err := fn(s)
44 require.NoError(l.Lazy().T(), err, "Failed to reset test server")
45 }
46 }
47
48 return s, nil
49 },
50 func(s *TestServer) error {
51 s.Close()
52 return nil
53 },
54 )
55}
56
57// NewTestServer creates and starts new http.TestServer
58func NewTestServer() *TestServer {

Callers 3

SetupSuiteMethod · 0.92
SetupSuiteMethod · 0.92
SetupSuiteMethod · 0.92

Calls 5

CloseMethod · 0.95
NewLazySuiteObjFunction · 0.85
TMethod · 0.80
NewTestServerFunction · 0.70
LazyMethod · 0.65

Tested by 3

SetupSuiteMethod · 0.74
SetupSuiteMethod · 0.74
SetupSuiteMethod · 0.74