mirror of
https://github.com/TECHNOFAB11/dbmate.git
synced 2025-12-11 23:50:04 +01:00
parent
2b61b4375a
commit
11c251bd25
2 changed files with 30 additions and 1 deletions
20
main_test.go
20
main_test.go
|
|
@ -35,3 +35,23 @@ func TestGetDatabaseUrl(t *testing.T) {
|
|||
require.Equal(t, "example.org", u.Host)
|
||||
require.Equal(t, "/db", u.Path)
|
||||
}
|
||||
|
||||
func TestRedactLogString(t *testing.T) {
|
||||
examples := []struct {
|
||||
in string
|
||||
expected string
|
||||
}{
|
||||
{"normal string",
|
||||
"normal string"},
|
||||
// malformed URL example (note forward slash in password)
|
||||
{"parse \"mysql://username:otS33+tb/e4=@localhost:3306/database\": invalid",
|
||||
"parse \"mysql://username:********@localhost:3306/database\": invalid"},
|
||||
// invalid port, but probably not a password since there is no @
|
||||
{"parse \"mysql://localhost:abc/database\": invalid",
|
||||
"parse \"mysql://localhost:abc/database\": invalid"},
|
||||
}
|
||||
|
||||
for _, ex := range examples {
|
||||
require.Equal(t, ex.expected, redactLogString(ex.in))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue