返回 DeepSeek-Reasonix
usecapability_inspect_test.go
根目录 / internal / agent / usecapability_inspect_test.go
1 package agent
2
3 import (
4 "encoding/json"
5 "strings"
6 "testing"
7 )
8
9 func TestMarshalBoundedInspectHardLimit(t *testing.T) {
10 payload := map[string]any{
11 "id": "mcp-tool:svc/read",
12 "description": strings.Repeat("oversized third-party description ", 4000),
13 "input_schema": json.RawMessage(`{"type":"object"}`),
14 "note": strings.Repeat("untrusted metadata ", 4000),
15 }
16 got := marshalBoundedInspect(payload)
17 if len(got) > maxInspectBytes {
18 t.Fatalf("inspect bytes = %d, want <= %d", len(got), maxInspectBytes)
19 }
20 if !json.Valid([]byte(got)) {
21 t.Fatalf("bounded inspect is invalid JSON: %q", got)
22 }
23 if !strings.Contains(got, `"truncated": true`) {
24 t.Fatalf("bounded inspect did not disclose truncation: %s", got)
25 }
26 }
27
27 lines GO