MCPcopy
hub / github.com/pocketbase/pocketbase / TestFieldsListRemove

Function TestFieldsListRemove

core/fields_list_test.go:141–170  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

139}
140
141func TestFieldsListRemove(t *testing.T) {
142 testFieldsList := core.NewFieldsList(
143 &core.TextField{Id: "id1", Name: "test1"},
144 &core.TextField{Id: "id2", Name: "test2"},
145 &core.TextField{Id: "id3", Name: "test3"},
146 &core.TextField{Id: "id4", Name: "test4"},
147 &core.TextField{Id: "id5", Name: "test5"},
148 &core.TextField{Id: "id6", Name: "test6"},
149 )
150
151 // remove by id
152 testFieldsList.RemoveById("id2")
153 testFieldsList.RemoveById("test3") // should do nothing
154
155 // remove by name
156 testFieldsList.RemoveByName("test5")
157 testFieldsList.RemoveByName("id6") // should do nothing
158
159 expected := []string{"test1", "test3", "test4", "test6"}
160
161 if len(testFieldsList) != len(expected) {
162 t.Fatalf("Expected %d, got %d\n%v", len(expected), len(testFieldsList), testFieldsList)
163 }
164
165 for _, name := range expected {
166 if f := testFieldsList.GetByName(name); f == nil {
167 t.Fatalf("Missing field %q", name)
168 }
169 }
170}
171
172func TestFieldsListAdd(t *testing.T) {
173 f0 := &core.TextField{}

Callers

nothing calls this directly

Calls 4

RemoveByIdMethod · 0.95
RemoveByNameMethod · 0.95
GetByNameMethod · 0.95
NewFieldsListFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…