TestHandler_SDKv2_PlainJSON_WithDB tests that v2 events with ISO timestamps are stored correctly in structured storage.
(t *testing.T)
| 520 | // TestHandler_SDKv2_PlainJSON_WithDB tests that v2 events with ISO timestamps |
| 521 | // are stored correctly in structured storage. |
| 522 | func TestHandler_SDKv2_PlainJSON_WithDB(t *testing.T) { |
| 523 | db := setupTestDB(t) |
| 524 | h := &handler{db: db} |
| 525 | |
| 526 | payload := `{"event_id":"v2-db-test","timestamp":"2026-03-31T12:44:44Z","level":"error","platform":"php","sdk":{"name":"sentry.php","version":"2.5.2"},"server_name":"web-01","environment":"production","message":"v2 db test","exception":{"values":[{"type":"RuntimeException","value":"v2 boom"}]}}` |
| 527 | |
| 528 | r := httptest.NewRequest("POST", "/api/1/store", strings.NewReader(payload)) |
| 529 | r.Header.Set("X-Sentry-Auth", "Sentry sentry_version=7, sentry_client=sentry.php/2.5.2, sentry_key=test") |
| 530 | |
| 531 | inc, err := h.Handle(r) |
| 532 | if err != nil { |
| 533 | t.Fatalf("Handle() error: %v", err) |
| 534 | } |
| 535 | if inc == nil { |
| 536 | t.Fatal("Handle() returned nil") |
| 537 | } |
| 538 | |
| 539 | // Verify event was stored in structured storage. |
| 540 | var count int |
| 541 | err = db.QueryRow("SELECT COUNT(*) FROM sentry_error_events WHERE event_id = 'v2-db-test'").Scan(&count) |
| 542 | if err != nil { |
| 543 | t.Fatalf("query error: %v", err) |
| 544 | } |
| 545 | if count != 1 { |
| 546 | t.Errorf("sentry_error_events count = %d, want 1 (v2 ISO timestamp must be handled)", count) |
| 547 | } |
| 548 | |
| 549 | // Verify exception was stored. |
| 550 | err = db.QueryRow("SELECT COUNT(*) FROM sentry_exceptions").Scan(&count) |
| 551 | if err != nil { |
| 552 | t.Fatalf("query error: %v", err) |
| 553 | } |
| 554 | if count != 1 { |
| 555 | t.Errorf("sentry_exceptions count = %d, want 1", count) |
| 556 | } |
| 557 | } |
| 558 | |
| 559 | // TestHandler_MessageAsObject tests that events with structured message objects |
| 560 | // (message with params, used by v3/v4 with parameterized messages) are handled. |
nothing calls this directly
no test coverage detected