MCPcopy
hub / github.com/pocketbase/pocketbase / TestPasswordFieldPrepareValue

Function TestPasswordFieldPrepareValue

core/field_password_test.go:33–68  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

31}
32
33func TestPasswordFieldPrepareValue(t *testing.T) {
34 app, _ := tests.NewTestApp()
35 defer app.Cleanup()
36
37 f := &core.PasswordField{}
38 record := core.NewRecord(core.NewBaseCollection("test"))
39
40 scenarios := []struct {
41 raw any
42 expected string
43 }{
44 {"", ""},
45 {"test", "test"},
46 {false, "false"},
47 {true, "true"},
48 {123.456, "123.456"},
49 }
50
51 for i, s := range scenarios {
52 t.Run(fmt.Sprintf("%d_%#v", i, s.raw), func(t *testing.T) {
53 v, err := f.PrepareValue(record, s.raw)
54 if err != nil {
55 t.Fatal(err)
56 }
57
58 pv, ok := v.(*core.PasswordFieldValue)
59 if !ok {
60 t.Fatalf("Expected PasswordFieldValue instance, got %T", v)
61 }
62
63 if pv.Hash != s.expected {
64 t.Fatalf("Expected %q, got %q", s.expected, v)
65 }
66 })
67 }
68}
69
70func TestPasswordFieldDriverValue(t *testing.T) {
71 app, _ := tests.NewTestApp()

Callers

nothing calls this directly

Calls 6

CleanupMethod · 0.95
PrepareValueMethod · 0.95
NewTestAppFunction · 0.92
NewRecordFunction · 0.92
NewBaseCollectionFunction · 0.92
RunMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…