返回 DeepSeek-Reasonix
protocol_metrics_test.go
根目录 / internal / plugin / protocol_metrics_test.go
1 package plugin
2
3 import (
4 "encoding/json"
5 "testing"
6 "time"
7 )
8
9 func TestObserveProtocolRecordsToolsListShape(t *testing.T) {
10 ResetProtocolMetricsForTest()
11 c := &Client{name: "m"}
12 res, _ := json.Marshal(map[string]any{"tools": []map[string]any{
13 {"name": "a", "inputSchema": map[string]any{"type": "object"}},
14 {"name": "b", "inputSchema": map[string]any{"type": "object", "properties": map[string]any{"q": map[string]any{"type": "string"}}}},
15 }})
16 c.observeProtocol("tools/list", res, 12*time.Millisecond, nil)
17 got := SnapshotToolsListStats()
18 if got.Count != 1 || got.Remote != 1 || got.ToolCount != 2 || got.DurationMs < 12 || got.SchemaBytes <= 0 {
19 t.Fatalf("stats = %+v", got)
20 }
21 }
22
22 lines GO