mirror of
https://github.com/wneessen/go-mail.git
synced 2024-12-18 17:00:38 +01:00
Improve error handling in connection pool tests
Add error checks to Close() calls in connpool_test.go to ensure connection closures are handled properly, with descriptive error messages. Update comment in connpool.go to improve clarity on the source of code inspiration.
This commit is contained in:
parent
f1188bdad7
commit
774925078a
2 changed files with 8 additions and 5 deletions
|
@ -12,9 +12,8 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Parts of the connection pool code is forked from https://github.com/fatih/pool/
|
// Parts of the connection pool code is forked/took inspiration from https://github.com/fatih/pool/
|
||||||
// Thanks to Fatih Arslan and the project contributors for providing this great
|
// Thanks to Fatih Arslan and the project contributors for providing this great concurrency template.
|
||||||
// concurrency template.
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// ErrClosed is returned when an operation is attempted on a closed connection pool.
|
// ErrClosed is returned when an operation is attempted on a closed connection pool.
|
||||||
|
|
|
@ -175,7 +175,9 @@ func TestPoolConn_Close(t *testing.T) {
|
||||||
conns[i] = conn
|
conns[i] = conn
|
||||||
}
|
}
|
||||||
for _, conn := range conns {
|
for _, conn := range conns {
|
||||||
conn.Close()
|
if err = conn.Close(); err != nil {
|
||||||
|
t.Errorf("failed to close connection: %s", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if p.Size() != 30 {
|
if p.Size() != 30 {
|
||||||
|
@ -191,7 +193,9 @@ func TestPoolConn_Close(t *testing.T) {
|
||||||
}
|
}
|
||||||
p.Close()
|
p.Close()
|
||||||
|
|
||||||
conn.Close()
|
if err = conn.Close(); err != nil {
|
||||||
|
t.Errorf("failed to close connection: %s", err)
|
||||||
|
}
|
||||||
if p.Size() != 0 {
|
if p.Size() != 0 {
|
||||||
t.Errorf("closed pool shouldn't allow to put connections.")
|
t.Errorf("closed pool shouldn't allow to put connections.")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue