MCPcopy Create free account
hub / github.com/bytebase/bytebase / TestApiRequest_ErrorParsing

Function TestApiRequest_ErrorParsing

backend/api/mcp/tool_http_test.go:47–60  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

45}
46
47func TestApiRequest_ErrorParsing(t *testing.T) {
48 s := newTestServerWithMock(t, http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
49 w.WriteHeader(http.StatusForbidden)
50 fmt.Fprint(w, `{"message": "permission denied", "code": "PERMISSION_DENIED"}`)
51 }))
52
53 ctx := context.Background()
54 resp, err := s.apiRequest(ctx, "/api/test", nil)
55 require.NoError(t, err)
56 require.Equal(t, http.StatusForbidden, resp.Status)
57
58 errMsg := parseError(resp.Body)
59 require.Equal(t, "permission denied", errMsg)
60}
61
62func TestApiRequest_RawMessage(t *testing.T) {
63 const payload = `{"id":12345,"count":9999999999}`

Callers

nothing calls this directly

Calls 4

newTestServerWithMockFunction · 0.85
parseErrorFunction · 0.85
apiRequestMethod · 0.80
EqualMethod · 0.65

Tested by

no test coverage detected