Files
谢宇宁andClaude Opus 5.5 3639d2184a Initial commit
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 14:47:17 +07:00

25 lines
782 B
Go

package playletser
import "testing"
func TestBuildThemeIndexPage(t *testing.T) {
themes := make([]PlayletThemeItem, 0, 23)
for i := 1; i <= 23; i++ {
themes = append(themes, PlayletThemeItem{ID: int64(i), Name: "专题", Status: true})
}
themes[1].Status = false
themes[2].Name = ""
first, total := BuildThemeIndexPage(themes, ParseThemeIndexQuery("1"))
if total != 21 || len(first) != 20 {
t.Fatalf("first page = (%d, %d), want (20, 21)", len(first), total)
}
second, _ := BuildThemeIndexPage(themes, ParseThemeIndexQuery("2"))
if len(second) != 1 {
t.Fatalf("second page length = %d, want 1", len(second))
}
if got := ThemeIndexCanonicalPath(ParseThemeIndexQuery("2")); got != "/topic/page/2" {
t.Fatalf("canonical path = %q, want /topic/page/2", got)
}
}