MCPcopy
hub / github.com/pocketbase/pocketbase / TestInternalRequestValidate

Function TestInternalRequestValidate

core/event_request_batch_test.go:12–74  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func TestInternalRequestValidate(t *testing.T) {
13 scenarios := []struct {
14 name string
15 request core.InternalRequest
16 expectedErrors []string
17 }{
18 {
19 "empty struct",
20 core.InternalRequest{},
21 []string{"method", "url"},
22 },
23
24 // method
25 {
26 "GET method",
27 core.InternalRequest{URL: "test", Method: http.MethodGet},
28 []string{},
29 },
30 {
31 "POST method",
32 core.InternalRequest{URL: "test", Method: http.MethodPost},
33 []string{},
34 },
35 {
36 "PUT method",
37 core.InternalRequest{URL: "test", Method: http.MethodPut},
38 []string{},
39 },
40 {
41 "PATCH method",
42 core.InternalRequest{URL: "test", Method: http.MethodPatch},
43 []string{},
44 },
45 {
46 "DELETE method",
47 core.InternalRequest{URL: "test", Method: http.MethodDelete},
48 []string{},
49 },
50 {
51 "unknown method",
52 core.InternalRequest{URL: "test", Method: "unknown"},
53 []string{"method"},
54 },
55
56 // url
57 {
58 "url <= 2000",
59 core.InternalRequest{URL: strings.Repeat("a", 2000), Method: http.MethodGet},
60 []string{},
61 },
62 {
63 "url > 2000",
64 core.InternalRequest{URL: strings.Repeat("a", 2001), Method: http.MethodGet},
65 []string{"url"},
66 },
67 }
68
69 for _, s := range scenarios {

Callers

nothing calls this directly

Calls 3

TestValidationErrorsFunction · 0.92
ValidateMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…