MCPcopy Create free account
hub / github.com/github/gh-aw / TestSanitizeErrorMessage_RealWorldExamples

Function TestSanitizeErrorMessage_RealWorldExamples

pkg/stringutil/sanitize_test.go:251–285  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

249}
250
251func TestSanitizeErrorMessage_RealWorldExamples(t *testing.T) {
252 tests := []struct {
253 name string
254 message string
255 expected string
256 }{
257 {
258 name: "GitHub Actions error",
259 message: "Failed to authenticate: GITHUB_TOKEN is invalid",
260 expected: "Failed to authenticate: [REDACTED] is invalid",
261 },
262 {
263 name: "AWS credentials error",
264 message: "AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are required",
265 expected: "[REDACTED] and [REDACTED] are required",
266 },
267 {
268 name: "Database connection error",
269 message: "Could not connect using DB_PASSWORD: connection refused",
270 expected: "Could not connect using [REDACTED]: connection refused",
271 },
272 {
273 name: "API error with token",
274 message: "Request failed with ApiToken: 401 Unauthorized",
275 expected: "Request failed with [REDACTED]: 401 Unauthorized",
276 },
277 }
278
279 for _, tt := range tests {
280 t.Run(tt.name, func(t *testing.T) {
281 result := SanitizeErrorMessage(tt.message)
282 assertSanitizeResult(t, "SanitizeErrorMessage", tt.message, result, tt.expected)
283 })
284 }
285}
286
287func BenchmarkSanitizeErrorMessage_NoSecrets(b *testing.B) {
288 message := "This is a regular error message with no secrets to redact"

Callers

nothing calls this directly

Calls 3

SanitizeErrorMessageFunction · 0.85
assertSanitizeResultFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected