MCPcopy Index your code
hub / github.com/pocketbase/pocketbase / TestNewInternalServerError

Function TestNewInternalServerError

tools/router/error_test.go:180–203  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

178}
179
180func TestNewInternalServerError(t *testing.T) {
181 t.Parallel()
182
183 scenarios := []struct {
184 message string
185 data any
186 expected string
187 }{
188 {"", nil, `{"data":{},"message":"Something went wrong while processing your request.","status":500}`},
189 {"demo", "rawData_test", `{"data":{},"message":"Demo.","status":500}`},
190 {"demo", validation.Errors{"err1": validation.NewError("test_code", "test_message")}, `{"data":{"err1":{"code":"test_code","message":"Test_message."}},"message":"Demo.","status":500}`},
191 }
192
193 for i, s := range scenarios {
194 t.Run(strconv.Itoa(i), func(t *testing.T) {
195 e := router.NewInternalServerError(s.message, s.data)
196 result, _ := json.Marshal(e)
197
198 if str := string(result); str != s.expected {
199 t.Fatalf("Expected\n%v\ngot\n%v", s.expected, str)
200 }
201 })
202 }
203}
204
205func TestNewTooManyRequestsError(t *testing.T) {
206 t.Parallel()

Callers

nothing calls this directly

Calls 2

NewInternalServerErrorFunction · 0.92
RunMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…