Files
bookhoard/internal/handlers/collections_test.go
T
John O'Keefe c54430c254 fix(podcasts): code-review pass over the session's UI surfaces
Findings from the systematic gotcha-class review before the browser
pass:

- The collection smart editor's Apply derived the collection NAME from
  document.title — which parses to "Smart Collection", RENAMING the
  collection on every apply. The server now renders the real name
  (data-collection-name) and the write path refuses to proceed without
  it.
- TestRenderingPartialsRender pinned the pre-episode-collections
  empty-state copy ("No books in this collection yet.") — updated to
  the shipped label ("Nothing in this collection yet."; collections
  hold episodes now).
- The deleted handler-local rule comparators (evaluateRule/
  compareValues — removed in item 3.4's single-evaluator refactor)
  left behind two unit-test files testing the duplicates; deleted.
  Their semantics remain covered at the service level
  (TestEvaluateRules_* over FieldMatches/EvaluateRules) and
  TestTextToString (which actually pins utils.PgTextString) stays.

Everything else reviewed clean against the gotcha classes: templ
whole-expression attrs, ?={ boolean attrs, JSONArg quoting in
x-init/data attrs, Alpine CSP store paths, htmx form-encoding, the
" assert escaping, and the aria-label selector contract on the
player's reload listener.
2026-10-30 19:38:39 -04:00

29 lines
545 B
Go

package handlers
import (
"testing"
"bookhoard/internal/utils"
"github.com/jackc/pgx/v5/pgtype"
"github.com/stretchr/testify/assert"
)
func TestTextToString(t *testing.T) {
tests := []struct {
name string
input pgtype.Text
expected string
}{
{"valid text", pgtype.Text{String: "hello", Valid: true}, "hello"},
{"null text", pgtype.Text{Valid: false}, ""},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result := utils.PgTextString(tt.input)
assert.Equal(t, tt.expected, result)
})
}
}