MCPcopy
hub / github.com/Tencent/WeKnora / newTestClient

Function newTestClient

cli/cmd/api/api_test.go:39–43  ·  view source on GitHub ↗

newTestClient stands up an httptest server with the supplied handler and returns an *sdk.Client targeting it plus a teardown closure. The real SDK is used so we exercise the same Raw() code path as production (header injection, JSON marshalling, etc.).

(t *testing.T, h http.HandlerFunc)

Source from the content-addressed store, hash-verified

37// used so we exercise the same Raw() code path as production (header
38// injection, JSON marshalling, etc.).
39func newTestClient(t *testing.T, h http.HandlerFunc) (*sdk.Client, func()) {
40 t.Helper()
41 srv := httptest.NewServer(h)
42 return sdk.NewClient(srv.URL), srv.Close
43}
44
45func TestAPI_GetSuccess(t *testing.T) {
46 out, _ := iostreams.SetForTest(t)

Callers 8

TestAPI_GetSuccessFunction · 0.70
TestAPI_GetSuccess_JSONFunction · 0.70
TestAPI_InputFileFunction · 0.70
TestAPI_InputDash_StdinFunction · 0.70
TestAPI_NotFoundFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected