test connection pools
All checks were successful
Build and Publish / BuildAndDeployAmd64 (push) Successful in 28s
Build and Publish / BuildAndDeploy (push) Successful in 2m32s

This commit is contained in:
matst80
2024-11-21 22:20:41 +01:00
parent 3d55c4ed1f
commit 933f0bb04f
3 changed files with 28 additions and 21 deletions

View File

@@ -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)
}
}