feat(wasm-plugin): add jsonrpc-converter plugin (#2805)

This commit is contained in:
澄潭
2025-08-28 19:28:37 +08:00
committed by GitHub
parent 44c33617fa
commit 3e0a5f02a7
9 changed files with 416 additions and 3 deletions

View File

@@ -0,0 +1,28 @@
package main
import (
"testing"
)
func TestTruncateString(t *testing.T) {
tests := []struct {
name string
input string
maxLen int
expected string
}{
{"Short String", "Higress Is an AI-Native API Gateway", 1000, "Higress Is an AI-Native API Gateway"},
{"Exact Length", "Higress Is an AI-Native API Gateway", 35, "Higress Is an AI-Native API Gateway"},
{"Truncated String", "Higress Is an AI-Native API Gateway", 20, "Higress Is...(truncated)...PI Gateway"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
config := McpConverterConfig{MaxHeaderLength: tt.maxLen}
result := truncateString(tt.input, config)
if result != tt.expected {
t.Errorf("truncateString(%q, %d) = %q; want %q", tt.input, tt.maxLen, result, tt.expected)
}
})
}
}