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

Function TestAPI_DeleteAll

internal/server/http/api_test.go:218–242  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

216}
217
218func TestAPI_DeleteAll(t *testing.T) {
219 mux, store := setupAPI(t)
220 ctx := context.Background()
221
222 for _, ev := range []event.Event{
223 {UUID: "d1", Type: "sentry", Payload: json.RawMessage(`{}`), Timestamp: 1.0, Project: "default"},
224 {UUID: "d2", Type: "ray", Payload: json.RawMessage(`{}`), Timestamp: 2.0, Project: "default"},
225 } {
226 store.Store(ctx, ev)
227 }
228
229 body := `{"type":"sentry"}`
230 r := httptest.NewRequest("DELETE", "/api/events", strings.NewReader(body))
231 w := httptest.NewRecorder()
232 mux.ServeHTTP(w, r)
233
234 if w.Code != 200 {
235 t.Fatalf("status = %d", w.Code)
236 }
237
238 all, _ := store.FindAll(ctx, event.FindOptions{})
239 if len(all) != 1 {
240 t.Errorf("len = %d, want 1", len(all))
241 }
242}
243
244func TestAPI_Projects(t *testing.T) {
245 mux, _ := setupAPI(t)

Callers

nothing calls this directly

Calls 4

setupAPIFunction · 0.85
ServeHTTPMethod · 0.80
StoreMethod · 0.65
FindAllMethod · 0.65

Tested by

no test coverage detected