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

Function TestDSNTLSConfig

dsn_test.go:250–276  ·  dsn_test.go::TestDSNTLSConfig
(t *testing.T)

Source from the content-addressed store, hash-verified

248}
249
250func TestDSNTLSConfig(t *testing.T) {
251 expectedServerName := "example.com"
252 dsn := "tcp(example.com:1234)/?tls=true"
253
254 cfg, err := ParseDSN(dsn)
255 if err != nil {
256 t.Error(err.Error())
257 }
258 if cfg.TLS == nil {
259 t.Error("cfg.tls should not be nil")
260 }
261 if cfg.TLS.ServerName != expectedServerName {
262 t.Errorf("cfg.tls.ServerName should be %q, got %q (host with port)", expectedServerName, cfg.TLS.ServerName)
263 }
264
265 dsn = "tcp(example.com)/?tls=true"
266 cfg, err = ParseDSN(dsn)
267 if err != nil {
268 t.Error(err.Error())
269 }
270 if cfg.TLS == nil {
271 t.Error("cfg.tls should not be nil")
272 }
273 if cfg.TLS.ServerName != expectedServerName {
274 t.Errorf("cfg.tls.ServerName should be %q, got %q (host without port)", expectedServerName, cfg.TLS.ServerName)
275 }
276}
277
278func TestDSNWithCustomTLSQueryEscape(t *testing.T) {
279 const configKey = "&%!:"

Callers

nothing calls this directly

Calls 2

ParseDSNFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected