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

Function TestEmptyPassword

driver_test.go:2371–2395  ·  view source on GitHub ↗

See Issue #799

(t *testing.T)

Source from the content-addressed store, hash-verified

2369
2370// See Issue #799
2371func TestEmptyPassword(t *testing.T) {
2372 if !available {
2373 t.Skipf("MySQL server not running on %s", netAddr)
2374 }
2375
2376 dsn := fmt.Sprintf("%s:%s@%s/%s?timeout=30s", user, "", netAddr, dbname)
2377 db, err := sql.Open(driverNameTest, dsn)
2378 if err == nil {
2379 defer db.Close()
2380 err = db.Ping()
2381 }
2382
2383 if pass == "" {
2384 if err != nil {
2385 t.Fatal(err.Error())
2386 }
2387 } else {
2388 if err == nil {
2389 t.Fatal("expected authentication error")
2390 }
2391 if !strings.HasPrefix(err.Error(), "Error 1045") {
2392 t.Fatal(err.Error())
2393 }
2394 }
2395}
2396
2397// static interface implementation checks of mysqlConn
2398var (

Callers

nothing calls this directly

Calls 4

OpenMethod · 0.80
PingMethod · 0.80
CloseMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected