- page/limit defaulting tested stale 'ok' from earlier type assertion
(list_repo_pull_requests, list_repo_commits, check_notifications,
list_repo_notifications) — now zero-default like all other handlers
- list_repo_issues: wire 'type' filter to SDK ListIssueOption.Type
- list_repo_pull_requests: wire 'milestone' to opt.Milestone; drop
unimplementable 'labels' param from schema (SDK has no labels filter)
- search_users / search_org_teams: honor page/limit via ListOptions
- delete_file: forward new_branch_name to FileOptions
- label resources: parse documented {?page,limit} query (cap 30) + tests
- cmd: -d/-debug default true→false; FORGEJO_DEBUG fallback reachable
- resources: rune-safe 200-byte excerpts via resource.Excerpt + tests
- docs: DoJSON isList comment, validateSHA lowercase claim
Closes beads: fcm 9ii cdf 3nu tc6 7f8 r7h cv4 yea
34 lines
785 B
Go
34 lines
785 B
Go
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
package resource
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
"unicode/utf8"
|
|
)
|
|
|
|
func TestExcerptShortStringUnchanged(t *testing.T) {
|
|
if got := Excerpt("hello", 200); got != "hello" {
|
|
t.Fatalf("got %q", got)
|
|
}
|
|
}
|
|
|
|
func TestExcerptTruncatesOnRuneBoundary(t *testing.T) {
|
|
// "é" is 2 bytes; place a multibyte rune straddling the cut point.
|
|
s := strings.Repeat("a", 199) + "éxxxx"
|
|
got := Excerpt(s, 200)
|
|
if !utf8.ValidString(got) {
|
|
t.Fatalf("excerpt is not valid UTF-8: %q", got)
|
|
}
|
|
if want := strings.Repeat("a", 199) + "…"; got != want {
|
|
t.Fatalf("got %q, want %q", got, want)
|
|
}
|
|
}
|
|
|
|
func TestExcerptExactLimitNoEllipsis(t *testing.T) {
|
|
s := strings.Repeat("a", 200)
|
|
if got := Excerpt(s, 200); got != s {
|
|
t.Fatalf("got %q", got)
|
|
}
|
|
}
|