| 216 | } |
| 217 | |
| 218 | func 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 | |
| 244 | func TestAPI_Projects(t *testing.T) { |
| 245 | mux, _ := setupAPI(t) |