MCPcopy
hub / github.com/pocketbase/pocketbase / TestEventHTML

Function TestEventHTML

tools/router/event_test.go:382–409  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

380}
381
382func TestEventHTML(t *testing.T) {
383 scenarios := []testResponseWriteScenario[string]{
384 {
385 name: "no explicit content-type",
386 status: 234,
387 headers: nil,
388 body: "test",
389 expectedStatus: 234,
390 expectedHeaders: map[string]string{"content-type": "text/html; charset=utf-8"},
391 expectedBody: "test",
392 },
393 {
394 name: "with explicit content-type",
395 status: 234,
396 headers: map[string]string{"content-type": "text/test"},
397 body: "test",
398 expectedStatus: 234,
399 expectedHeaders: map[string]string{"content-type": "text/test"},
400 expectedBody: "test",
401 },
402 }
403
404 for _, s := range scenarios {
405 testEventResponseWrite(t, s, func(e *router.Event) error {
406 return e.HTML(s.status, s.body)
407 })
408 }
409}
410
411func TestEventJSON(t *testing.T) {
412 body := map[string]any{"a": 123, "b": 456, "c": "test"}

Callers

nothing calls this directly

Calls 2

testEventResponseWriteFunction · 0.85
HTMLMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…