(t *testing.T)
| 22 | } |
| 23 | |
| 24 | func TestSanitizeErrorMessage(t *testing.T) { |
| 25 | tests := []struct { |
| 26 | name string |
| 27 | message string |
| 28 | expected string |
| 29 | }{ |
| 30 | { |
| 31 | name: "empty message", |
| 32 | message: "", |
| 33 | expected: "", |
| 34 | }, |
| 35 | { |
| 36 | name: "message with no secrets", |
| 37 | message: "This is a regular error message", |
| 38 | expected: "This is a regular error message", |
| 39 | }, |
| 40 | { |
| 41 | name: "message with snake_case secret", |
| 42 | message: "Error accessing MY_SECRET_KEY", |
| 43 | expected: "Error accessing [REDACTED]", |
| 44 | }, |
| 45 | { |
| 46 | name: "message with multiple secrets", |
| 47 | message: "Failed to use API_TOKEN and DATABASE_PASSWORD", |
| 48 | expected: "Failed to use [REDACTED] and [REDACTED]", |
| 49 | }, |
| 50 | { |
| 51 | name: "message with PascalCase secret", |
| 52 | message: "Invalid GitHubToken provided", |
| 53 | expected: "Invalid [REDACTED] provided", |
| 54 | }, |
| 55 | { |
| 56 | name: "message with workflow keyword (not redacted)", |
| 57 | message: "Error in GITHUB_ACTIONS workflow", |
| 58 | expected: "Error in [REDACTED] workflow", |
| 59 | }, |
| 60 | { |
| 61 | name: "message with GITHUB keyword (not redacted)", |
| 62 | message: "GITHUB is not responding", |
| 63 | expected: "GITHUB is not responding", |
| 64 | }, |
| 65 | { |
| 66 | name: "message with PATH keyword (not redacted)", |
| 67 | message: "PATH variable is not set", |
| 68 | expected: "PATH variable is not set", |
| 69 | }, |
| 70 | { |
| 71 | name: "complex message with mixed secrets", |
| 72 | message: "Failed to authenticate with DEPLOY_KEY and ApiSecret", |
| 73 | expected: "Failed to authenticate with [REDACTED] and [REDACTED]", |
| 74 | }, |
| 75 | } |
| 76 | |
| 77 | for _, tt := range tests { |
| 78 | t.Run(tt.name, func(t *testing.T) { |
| 79 | result := SanitizeErrorMessage(tt.message) |
| 80 | assertSanitizeResult(t, "SanitizeErrorMessage", tt.message, result, tt.expected) |
| 81 | }) |
nothing calls this directly
no test coverage detected