MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / StartServerWithConfig

Function StartServerWithConfig

rest/utilities_testing_bootstrap.go:191–217  ·  view source on GitHub ↗

StartServerWithConfig starts a server from given config, and returns a function to close the server. Prefer use of RestTester for more ergonomic APIs.

(t *testing.T, config *StartupConfig)

Source from the content-addressed store, hash-verified

189
190// StartServerWithConfig starts a server from given config, and returns a function to close the server. Prefer use of RestTester for more ergonomic APIs.
191func StartServerWithConfig(t *testing.T, config *StartupConfig) (*ServerContext, func()) {
192 ctx := base.TestCtx(t)
193 sc, err := SetupServerContext(ctx, config, true)
194 require.NoError(t, err)
195
196 serverErr := make(chan error)
197
198 closeFn := func() {
199 sc.Close(ctx)
200 assert.NoError(t, <-serverErr)
201 }
202
203 started := false
204 defer func() {
205 if !started {
206 closeFn()
207 }
208
209 }()
210 go func() {
211 serverErr <- StartServer(ctx, config, sc)
212 }()
213
214 require.NoError(t, sc.WaitForRESTAPIs(ctx))
215 started = true
216 return sc, closeFn
217}

Calls 5

TestCtxFunction · 0.92
SetupServerContextFunction · 0.85
StartServerFunction · 0.85
WaitForRESTAPIsMethod · 0.80
CloseMethod · 0.65