MCPcopy Create free account
hub / github.com/convox/rack / testServer

Function testServer

pkg/api/api_test.go:18–39  ·  view source on GitHub ↗
(t *testing.T, fn func(*stdsdk.Client, *structs.MockProvider))

Source from the content-addressed store, hash-verified

16)
17
18func testServer(t *testing.T, fn func(*stdsdk.Client, *structs.MockProvider)) {
19 p := &structs.MockProvider{}
20 p.On("Initialize", mock.Anything).Return(nil)
21 p.On("WithContext", mock.Anything).Return(p).Maybe()
22 p.On("SystemJwtSignKey").Return("", nil)
23
24 s := api.NewWithProvider(p)
25 s.Logger = logger.Discard
26 s.Server.Recover = func(err error, c *stdapi.Context) {
27 require.NoError(t, err, "httptest server panic")
28 }
29
30 ht := httptest.NewServer(s)
31 defer ht.Close()
32
33 c, err := stdsdk.New(ht.URL)
34 require.NoError(t, err)
35
36 fn(c, p)
37
38 p.AssertExpectations(t)
39}
40
41func requestContextMatcher(ctx context.Context) bool {
42 _, ok := ctx.Value("request.id").(string)

Callers 15

TestInstanceKeyrollFunction · 0.70
TestInstanceKeyrollErrorFunction · 0.70
TestInstanceListFunction · 0.70
TestInstanceListErrorFunction · 0.70
TestInstanceShellFunction · 0.70
TestInstanceShellErrorFunction · 0.70
TestInstanceTerminateFunction · 0.70
TestServiceMetricsFunction · 0.70
TestServiceListFunction · 0.70
TestServiceListErrorFunction · 0.70
TestServiceRestartFunction · 0.70

Calls 2

NewWithProviderFunction · 0.92
CloseMethod · 0.45

Tested by

no test coverage detected