Skip to content

Commit

Permalink
TestDSNReformat: add more roundtrip checks
Browse files Browse the repository at this point in the history
Add more roundtrip checks for ParseDSN/FormatDSN.
  • Loading branch information
dolmen committed Jun 1, 2023
1 parent 397e2f5 commit 047b7c2
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions dsn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ func TestDSNReformat(t *testing.T) {
res1 := fmt.Sprintf("%+v", cfg1)

dsn2 := cfg1.FormatDSN()
if dsn2 != dsn1 {
// Just log
t.Logf("%d. %q reformated as %q", i, dsn1, dsn2)
}

cfg2, err := ParseDSN(dsn2)
if err != nil {
t.Error(err.Error())
Expand All @@ -139,8 +144,14 @@ func TestDSNReformat(t *testing.T) {
res2 := fmt.Sprintf("%+v", cfg2)

if res1 != res2 {
t.Errorf("%d. %q does not match %q", i, dsn2, dsn1)
t.Errorf("%d. %q does not match %q", i, res2, res1)
}

dsn3 := cfg2.FormatDSN()
if dsn3 != dsn2 {
t.Errorf("%d. %q does not match %q", i, dsn2, dsn3)
}
})
}
}
Expand Down

0 comments on commit 047b7c2

Please sign in to comment.