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

Function TestDSNUnsafeCollation

dsn_test.go:296–331  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

294}
295
296func TestDSNUnsafeCollation(t *testing.T) {
297 _, err := ParseDSN("/dbname?collation=gbk_chinese_ci&interpolateParams=true")
298 if err != errInvalidDSNUnsafeCollation {
299 t.Errorf("expected %v, got %v", errInvalidDSNUnsafeCollation, err)
300 }
301
302 _, err = ParseDSN("/dbname?collation=gbk_chinese_ci&interpolateParams=false")
303 if err != nil {
304 t.Errorf("expected %v, got %v", nil, err)
305 }
306
307 _, err = ParseDSN("/dbname?collation=gbk_chinese_ci")
308 if err != nil {
309 t.Errorf("expected %v, got %v", nil, err)
310 }
311
312 _, err = ParseDSN("/dbname?collation=ascii_bin&interpolateParams=true")
313 if err != nil {
314 t.Errorf("expected %v, got %v", nil, err)
315 }
316
317 _, err = ParseDSN("/dbname?collation=latin1_german1_ci&interpolateParams=true")
318 if err != nil {
319 t.Errorf("expected %v, got %v", nil, err)
320 }
321
322 _, err = ParseDSN("/dbname?collation=utf8_general_ci&interpolateParams=true")
323 if err != nil {
324 t.Errorf("expected %v, got %v", nil, err)
325 }
326
327 _, err = ParseDSN("/dbname?collation=utf8mb4_general_ci&interpolateParams=true")
328 if err != nil {
329 t.Errorf("expected %v, got %v", nil, err)
330 }
331}
332
333func TestParamsAreSorted(t *testing.T) {
334 expected := "/dbname?interpolateParams=true&foobar=baz&quux=loo"

Callers

nothing calls this directly

Calls 1

ParseDSNFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…