(t *testing.T)
| 476 | } |
| 477 | |
| 478 | func TestHandlerWithDB(t *testing.T) { |
| 479 | db := setupTestDB(t) |
| 480 | h := &handler{db: db} |
| 481 | |
| 482 | body := []byte(`{"event_id":"full-test"} |
| 483 | {"type":"event","length":0} |
| 484 | {"event_id":"full-test","level":"warning","message":"test message","exception":{"values":[{"type":"TestException","value":"test"}]}}`) |
| 485 | |
| 486 | inc, err := h.handleEnvelope(body, "testproject") |
| 487 | if err != nil { |
| 488 | t.Fatal(err) |
| 489 | } |
| 490 | |
| 491 | if inc.UUID != "full-test" { |
| 492 | t.Errorf("UUID = %q, want 'full-test'", inc.UUID) |
| 493 | } |
| 494 | |
| 495 | // Verify structured data was stored. |
| 496 | var count int |
| 497 | db.QueryRow(`SELECT COUNT(*) FROM sentry_error_events`).Scan(&count) |
| 498 | if count != 1 { |
| 499 | t.Errorf("error events = %d, want 1", count) |
| 500 | } |
| 501 | |
| 502 | var excCount int |
| 503 | db.QueryRow(`SELECT COUNT(*) FROM sentry_exceptions`).Scan(&excCount) |
| 504 | if excCount != 1 { |
| 505 | t.Errorf("exceptions = %d, want 1", excCount) |
| 506 | } |
| 507 | } |
nothing calls this directly
no test coverage detected