22 lines
776 B
Go
22 lines
776 B
Go
package messaging
|
|
|
|
import "testing"
|
|
|
|
func TestSummarizeToolParameters(t *testing.T) {
|
|
tests := []struct {
|
|
name, input, want string
|
|
}{
|
|
{"plain values are shown", `{"command":"git diff --stat"}`, `{"command":"git diff --stat"}`},
|
|
{"sensitive keys are redacted", `{"api_key":"sk-1","path":"a.go"}`, `{"api_key":"[redacted]","path":"a.go"}`},
|
|
{"nested sensitive keys are redacted", `{"headers":{"Authorization":"Bearer x"}}`, `{"headers":{"Authorization":"[redacted]"}}`},
|
|
{"unparseable input is withheld", `not json`, `[unavailable]`},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
if got := SummarizeToolParameters(tt.input); got != tt.want {
|
|
t.Fatalf("SummarizeToolParameters(%s) = %s, want %s", tt.input, got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|