test connection pools
This commit is contained in:
@@ -17,7 +17,7 @@ func TestGenericConnection(t *testing.T) {
|
||||
}
|
||||
pool, err := netpool.New(func() (net.Conn, error) {
|
||||
return net.Dial("tcp", "127.0.0.1:51337")
|
||||
}, netpool.WithMaxPool(512))
|
||||
}, netpool.WithMaxPool(512), netpool.WithMinPool(5))
|
||||
if err != nil {
|
||||
t.Errorf("Error creating pool: %v\n", err)
|
||||
}
|
||||
@@ -42,11 +42,12 @@ func TestGenericConnection(t *testing.T) {
|
||||
if r.Type != 2 {
|
||||
t.Errorf("Expected type 2, got %d\n", r.Type)
|
||||
}
|
||||
response, err := conn.Call(Ping, nil)
|
||||
if err != nil || response.StatusCode != 200 || response.Type != Pong {
|
||||
t.Errorf("Error connecting to remote %v\n", response)
|
||||
}
|
||||
|
||||
res, err := conn.Call(3, datta)
|
||||
if err != nil {
|
||||
t.Errorf("Did not expect error, got %v\n", err)
|
||||
return
|
||||
}
|
||||
if res.StatusCode == 200 {
|
||||
t.Errorf("Expected error, got %v\n", res)
|
||||
}
|
||||
@@ -65,4 +66,9 @@ func TestGenericConnection(t *testing.T) {
|
||||
i++
|
||||
}
|
||||
|
||||
response, err := conn.Call(Ping, nil)
|
||||
if err != nil || response.StatusCode != 200 || response.Type != Pong {
|
||||
t.Errorf("Error connecting to remote %v, err: %v\n", response, err)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user