selfcare init
This commit is contained in:
30
proxy_go/public/mysql@v1.6.0/connector_test.go
Normal file
30
proxy_go/public/mysql@v1.6.0/connector_test.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package mysql
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestConnectorReturnsTimeout(t *testing.T) {
|
||||
connector := &connector{&Config{
|
||||
Net: "tcp",
|
||||
Addr: "1.1.1.1:1234",
|
||||
Timeout: 10 * time.Millisecond,
|
||||
}}
|
||||
|
||||
_, err := connector.Connect(context.Background())
|
||||
if err == nil {
|
||||
t.Fatal("error expected")
|
||||
}
|
||||
|
||||
if nerr, ok := err.(*net.OpError); ok {
|
||||
expected := "dial tcp 1.1.1.1:1234: i/o timeout"
|
||||
if nerr.Error() != expected {
|
||||
t.Fatalf("expected %q, got %q", expected, nerr.Error())
|
||||
}
|
||||
} else {
|
||||
t.Fatalf("expected %T, got %T", nerr, err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user