mirror of
https://github.com/AdguardTeam/AdGuardDNS.git
synced 2025-02-20 11:23:36 +08:00
27 lines
339 B
Go
27 lines
339 B
Go
package upstream
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestConnPool(t *testing.T) {
|
|
pool := &connsPool{}
|
|
|
|
// empty pool
|
|
c := pool.Get()
|
|
assert.Nil(t, c)
|
|
c = &Conn{}
|
|
pool.Put(c)
|
|
|
|
// not empty
|
|
c2 := pool.Get()
|
|
assert.True(t, c == c2)
|
|
|
|
// closed
|
|
pool.Close()
|
|
pool.Put(c)
|
|
assert.Nil(t, pool.Get())
|
|
}
|