MCPcopy
hub / github.com/go-sql-driver/mysql / TestDSNParserInvalid

Function TestDSNParserInvalid

dsn_test.go:105–125  ·  dsn_test.go::TestDSNParserInvalid
(t *testing.T)

Source from the content-addressed store, hash-verified

103}
104
105func TestDSNParserInvalid(t *testing.T) {
106 var invalidDSNs = []string{
107 "@net(addr/", // no closing brace
108 "@tcp(/", // no closing brace
109 "tcp(/", // no closing brace
110 "(/", // no closing brace
111 "net(addr)//", // unescaped
112 "User:pass@tcp(1.2.3.4:3306)", // no trailing slash
113 "net()/", // unknown default addr
114 "user:pass@tcp(127.0.0.1:3306)/db/name", // invalid dbname
115 "user:password@/dbname?allowFallbackToPlaintext=PREFERRED", // wrong bool flag
116 "user:password@/dbname?connectionAttributes=attr1:/unescaped/value", // unescaped
117 //"/dbname?arg=/some/unescaped/path",
118 }
119
120 for i, tst := range invalidDSNs {
121 if _, err := ParseDSN(tst); err == nil {
122 t.Errorf("invalid DSN #%d. (%s) didn't error!", i, tst)
123 }
124 }
125}
126
127func TestDSNReformat(t *testing.T) {
128 for i, tst := range testDSNs {

Callers

nothing calls this directly

Calls 1

ParseDSNFunction · 0.85

Tested by

no test coverage detected