(tb testing.TB, beforeStarting func(app *fiber.App))
| 20 | } |
| 21 | |
| 22 | func startTestServer(tb testing.TB, beforeStarting func(app *fiber.App)) *testServer { |
| 23 | tb.Helper() |
| 24 | |
| 25 | ln := fasthttputil.NewInmemoryListener() |
| 26 | app := fiber.New(fiber.Config{ |
| 27 | CBOREncoder: cbor.Marshal, |
| 28 | CBORDecoder: cbor.Unmarshal, |
| 29 | }) |
| 30 | |
| 31 | if beforeStarting != nil { |
| 32 | beforeStarting(app) |
| 33 | } |
| 34 | |
| 35 | ch := make(chan struct{}) |
| 36 | go func() { |
| 37 | err := app.Listener(ln, fiber.ListenConfig{DisableStartupMessage: true}) |
| 38 | assert.NoError(tb, err) |
| 39 | |
| 40 | close(ch) |
| 41 | }() |
| 42 | |
| 43 | return &testServer{ |
| 44 | app: app, |
| 45 | ch: ch, |
| 46 | ln: ln, |
| 47 | tb: tb, |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | func (ts *testServer) stop() { |
| 52 | ts.tb.Helper() |
no test coverage detected