MCPcopy
hub / github.com/pocketbase/pocketbase / TestJoinValidationErrors

Function TestJoinValidationErrors

core/validators/validators_test.go:12–39  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func TestJoinValidationErrors(t *testing.T) {
13 scenarios := []struct {
14 errA error
15 errB error
16 expected string
17 }{
18 {nil, nil, "<nil>"},
19 {errors.New("abc"), nil, "abc"},
20 {nil, errors.New("abc"), "abc"},
21 {errors.New("abc"), errors.New("456"), "abc\n456"},
22 {validation.Errors{"test1": errors.New("test1_err")}, nil, "test1: test1_err."},
23 {nil, validation.Errors{"test2": errors.New("test2_err")}, "test2: test2_err."},
24 {validation.Errors{}, errors.New("456"), "\n456"},
25 {errors.New("456"), validation.Errors{}, "456\n"},
26 {validation.Errors{"test1": errors.New("test1_err")}, errors.New("456"), "test1: test1_err."},
27 {errors.New("456"), validation.Errors{"test2": errors.New("test2_err")}, "test2: test2_err."},
28 {validation.Errors{"test1": errors.New("test1_err")}, validation.Errors{"test2": errors.New("test2_err")}, "test1: test1_err; test2: test2_err."},
29 }
30
31 for i, s := range scenarios {
32 t.Run(fmt.Sprintf("%d_%#T_%T", i, s.errA, s.errB), func(t *testing.T) {
33 result := fmt.Sprintf("%v", validators.JoinValidationErrors(s.errA, s.errB))
34 if result != s.expected {
35 t.Fatalf("Expected\n%v\ngot\n%v", s.expected, result)
36 }
37 })
38 }
39}

Callers

nothing calls this directly

Calls 2

JoinValidationErrorsFunction · 0.92
RunMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…