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

Function TestFieldMapper

plugins/jsvm/mapper_test.go:10–42  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

8)
9
10func TestFieldMapper(t *testing.T) {
11 mapper := jsvm.FieldMapper{}
12
13 scenarios := []struct {
14 name string
15 expected string
16 }{
17 {"", ""},
18 {"test", "test"},
19 {"Test", "test"},
20 {"miXeD", "miXeD"},
21 {"MiXeD", "miXeD"},
22 {"ResolveRequestAsJSON", "resolveRequestAsJSON"},
23 {"Variable_with_underscore", "variable_with_underscore"},
24 {"ALLCAPS", "allcaps"},
25 {"ALL_CAPS_WITH_UNDERSCORE", "all_caps_with_underscore"},
26 {"OIDCMap", "oidcMap"},
27 {"MD5", "md5"},
28 {"OAuth2", "oauth2"},
29 }
30
31 for i, s := range scenarios {
32 field := reflect.StructField{Name: s.name}
33 if v := mapper.FieldName(nil, field); v != s.expected {
34 t.Fatalf("[%d] Expected FieldName %q, got %q", i, s.expected, v)
35 }
36
37 method := reflect.Method{Name: s.name}
38 if v := mapper.MethodName(nil, method); v != s.expected {
39 t.Fatalf("[%d] Expected MethodName %q, got %q", i, s.expected, v)
40 }
41 }
42}

Callers

nothing calls this directly

Calls 2

FieldNameMethod · 0.95
MethodNameMethod · 0.95

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…