- 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
44 lines
1.2 KiB
Go
44 lines
1.2 KiB
Go
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
package issue
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"codeberg.org/goern/forgejo-mcp/v2/operation/resource"
|
|
"github.com/mark3labs/mcp-go/mcp"
|
|
)
|
|
|
|
func readReq(uri string) mcp.ReadResourceRequest {
|
|
var req mcp.ReadResourceRequest
|
|
req.Params.URI = uri
|
|
return req
|
|
}
|
|
|
|
func TestPageLimitDefaults(t *testing.T) {
|
|
page, limit := pageLimit(readReq("forgejo://repo/o/r/labels"))
|
|
if page != 1 || limit != resource.EmbeddedListCap {
|
|
t.Fatalf("got page=%d limit=%d", page, limit)
|
|
}
|
|
}
|
|
|
|
func TestPageLimitFromQuery(t *testing.T) {
|
|
page, limit := pageLimit(readReq("forgejo://repo/o/r/labels?page=3&limit=5"))
|
|
if page != 3 || limit != 5 {
|
|
t.Fatalf("got page=%d limit=%d", page, limit)
|
|
}
|
|
}
|
|
|
|
func TestPageLimitClampsToCap(t *testing.T) {
|
|
_, limit := pageLimit(readReq("forgejo://org/o/labels?limit=999"))
|
|
if limit != resource.EmbeddedListCap {
|
|
t.Fatalf("got limit=%d, want cap %d", limit, resource.EmbeddedListCap)
|
|
}
|
|
}
|
|
|
|
func TestPageLimitIgnoresMalformed(t *testing.T) {
|
|
page, limit := pageLimit(readReq("forgejo://org/o/labels?page=abc&limit=-2"))
|
|
if page != 1 || limit != resource.EmbeddedListCap {
|
|
t.Fatalf("got page=%d limit=%d", page, limit)
|
|
}
|
|
}
|