MCPcopy Create free account
hub / github.com/buggregator/server / TestSQLiteStore_DeleteAll

Function TestSQLiteStore_DeleteAll

internal/storage/sqlite_test.go:181–223  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

179}
180
181func TestSQLiteStore_DeleteAll(t *testing.T) {
182 db := setupTestDB(t)
183 store := storage.NewSQLiteStore(db)
184 ctx := context.Background()
185
186 for _, ev := range []event.Event{
187 makeEvent("d1", "sentry", "proj-a"),
188 makeEvent("d2", "ray", "proj-a"),
189 makeEvent("d3", "sentry", "proj-b"),
190 } {
191 store.Store(ctx, ev)
192 }
193
194 t.Run("delete by UUIDs", func(t *testing.T) {
195 if err := store.DeleteAll(ctx, event.DeleteOptions{UUIDs: []string{"d1"}}); err != nil {
196 t.Fatal(err)
197 }
198 all, _ := store.FindAll(ctx, event.FindOptions{})
199 if len(all) != 2 {
200 t.Errorf("len = %d, want 2", len(all))
201 }
202 })
203
204 t.Run("delete by type", func(t *testing.T) {
205 if err := store.DeleteAll(ctx, event.DeleteOptions{Type: "sentry"}); err != nil {
206 t.Fatal(err)
207 }
208 all, _ := store.FindAll(ctx, event.FindOptions{})
209 if len(all) != 1 {
210 t.Errorf("len = %d, want 1", len(all))
211 }
212 })
213
214 t.Run("delete all", func(t *testing.T) {
215 if err := store.DeleteAll(ctx, event.DeleteOptions{}); err != nil {
216 t.Fatal(err)
217 }
218 all, _ := store.FindAll(ctx, event.FindOptions{})
219 if len(all) != 0 {
220 t.Errorf("len = %d, want 0", len(all))
221 }
222 })
223}
224
225func TestSQLiteStore_Pin_Unpin(t *testing.T) {
226 db := setupTestDB(t)

Callers

nothing calls this directly

Calls 7

StoreMethod · 0.95
DeleteAllMethod · 0.95
FindAllMethod · 0.95
NewSQLiteStoreFunction · 0.92
makeEventFunction · 0.85
setupTestDBFunction · 0.70
RunMethod · 0.45

Tested by

no test coverage detected