24 lines
515 B
Go
24 lines
515 B
Go
package mxgateway
|
|
|
|
import "testing"
|
|
|
|
func TestRedactAPIKey(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
apiKey string
|
|
want string
|
|
}{
|
|
{name: "empty", apiKey: "", want: ""},
|
|
{name: "short", apiKey: "mxgw_1", want: "<redacted>"},
|
|
{name: "long", apiKey: "mxgw_key_secret", want: "mxgw*******cret"},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
if got := RedactAPIKey(tt.apiKey); got != tt.want {
|
|
t.Fatalf("RedactAPIKey() = %q, want %q", got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|