MCPcopy
hub / github.com/pocketbase/pocketbase / TestFindAllOTPsByCollection

Function TestFindAllOTPsByCollection

core/otp_query_test.go:72–138  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

70}
71
72func TestFindAllOTPsByCollection(t *testing.T) {
73 t.Parallel()
74
75 app, _ := tests.NewTestApp()
76 defer app.Cleanup()
77
78 if err := tests.StubOTPRecords(app); err != nil {
79 t.Fatal(err)
80 }
81
82 demo1, err := app.FindCollectionByNameOrId("demo1")
83 if err != nil {
84 t.Fatal(err)
85 }
86
87 superusers, err := app.FindCollectionByNameOrId(core.CollectionNameSuperusers)
88 if err != nil {
89 t.Fatal(err)
90 }
91
92 clients, err := app.FindCollectionByNameOrId("clients")
93 if err != nil {
94 t.Fatal(err)
95 }
96
97 users, err := app.FindCollectionByNameOrId("users")
98 if err != nil {
99 t.Fatal(err)
100 }
101
102 scenarios := []struct {
103 collection *core.Collection
104 expected []string
105 }{
106 {demo1, nil},
107 {superusers, []string{
108 "superuser2_0",
109 "superuser2_1",
110 "superuser2_3",
111 "superuser3_0",
112 "superuser3_1",
113 "superuser2_2",
114 "superuser2_4",
115 }},
116 {clients, nil},
117 {users, []string{"user1_0"}},
118 }
119
120 for _, s := range scenarios {
121 t.Run(s.collection.Name, func(t *testing.T) {
122 result, err := app.FindAllOTPsByCollection(s.collection)
123 if err != nil {
124 t.Fatal(err)
125 }
126
127 if len(result) != len(s.expected) {
128 t.Fatalf("Expected total otps %d, got %d", len(s.expected), len(result))
129 }

Callers

nothing calls this directly

Calls 6

CleanupMethod · 0.95
NewTestAppFunction · 0.92
StubOTPRecordsFunction · 0.92
RunMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…