MCPcopy
hub / github.com/pocketbase/pocketbase / TestNewNotFoundError

Function TestNewNotFoundError

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

Source from the content-addressed store, hash-verified

78}
79
80func TestNewNotFoundError(t *testing.T) {
81 t.Parallel()
82
83 scenarios := []struct {
84 message string
85 data any
86 expected string
87 }{
88 {"", nil, `{"data":{},"message":"The requested resource wasn't found.","status":404}`},
89 {"demo", "rawData_test", `{"data":{},"message":"Demo.","status":404}`},
90 {"demo", validation.Errors{"err1": validation.NewError("test_code", "test_message")}, `{"data":{"err1":{"code":"test_code","message":"Test_message."}},"message":"Demo.","status":404}`},
91 }
92
93 for i, s := range scenarios {
94 t.Run(strconv.Itoa(i), func(t *testing.T) {
95 e := router.NewNotFoundError(s.message, s.data)
96 result, _ := json.Marshal(e)
97
98 if str := string(result); str != s.expected {
99 t.Fatalf("Expected\n%v\ngot\n%v", s.expected, str)
100 }
101 })
102 }
103}
104
105func TestNewBadRequestError(t *testing.T) {
106 t.Parallel()

Callers

nothing calls this directly

Calls 2

NewNotFoundErrorFunction · 0.92
RunMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…