Skip to content

Commit 047b7c2

Browse files
committed
TestDSNReformat: add more roundtrip checks
Add more roundtrip checks for ParseDSN/FormatDSN.
1 parent 397e2f5 commit 047b7c2

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Diff for: dsn_test.go

+11
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,11 @@ func TestDSNReformat(t *testing.T) {
130130
res1 := fmt.Sprintf("%+v", cfg1)
131131

132132
dsn2 := cfg1.FormatDSN()
133+
if dsn2 != dsn1 {
134+
// Just log
135+
t.Logf("%d. %q reformated as %q", i, dsn1, dsn2)
136+
}
137+
133138
cfg2, err := ParseDSN(dsn2)
134139
if err != nil {
135140
t.Error(err.Error())
@@ -139,8 +144,14 @@ func TestDSNReformat(t *testing.T) {
139144
res2 := fmt.Sprintf("%+v", cfg2)
140145

141146
if res1 != res2 {
147+
t.Errorf("%d. %q does not match %q", i, dsn2, dsn1)
142148
t.Errorf("%d. %q does not match %q", i, res2, res1)
143149
}
150+
151+
dsn3 := cfg2.FormatDSN()
152+
if dsn3 != dsn2 {
153+
t.Errorf("%d. %q does not match %q", i, dsn2, dsn3)
154+
}
144155
})
145156
}
146157
}

0 commit comments

Comments
 (0)