mirror of
https://github.com/redis/go-redis.git
synced 2025-04-17 20:17:02 +03:00
* run go fix ./... Signed-off-by: Tiago Peczenyj <tpeczenyj@weborama.com> * run make fmt Signed-off-by: Tiago Peczenyj <tpeczenyj@weborama.com> * fix go vet ./... issues * Update README.md Reorder imports with the rules defined in the Makefile as if we run `make fmt` * run gofumpt -w . * update Makefile to use gofumpt instead gofmt * increment makefile * format test * format tests Signed-off-by: Tiago Peczenyj <tpeczenyj@weborama.com> --------- Signed-off-by: Tiago Peczenyj <tpeczenyj@weborama.com> Co-authored-by: ofekshenawa <104765379+ofekshenawa@users.noreply.github.com>
48 lines
1.1 KiB
Go
48 lines
1.1 KiB
Go
//go:build linux || darwin || dragonfly || freebsd || netbsd || openbsd || solaris || illumos
|
|
|
|
package pool
|
|
|
|
import (
|
|
"net"
|
|
"net/http/httptest"
|
|
"time"
|
|
|
|
. "github.com/bsm/ginkgo/v2"
|
|
. "github.com/bsm/gomega"
|
|
)
|
|
|
|
var _ = Describe("tests conn_check with real conns", func() {
|
|
var ts *httptest.Server
|
|
var conn net.Conn
|
|
var err error
|
|
|
|
BeforeEach(func() {
|
|
ts = httptest.NewServer(nil)
|
|
conn, err = net.DialTimeout(ts.Listener.Addr().Network(), ts.Listener.Addr().String(), time.Second)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
})
|
|
|
|
AfterEach(func() {
|
|
ts.Close()
|
|
})
|
|
|
|
It("good conn check", func() {
|
|
Expect(connCheck(conn)).NotTo(HaveOccurred())
|
|
|
|
Expect(conn.Close()).NotTo(HaveOccurred())
|
|
Expect(connCheck(conn)).To(HaveOccurred())
|
|
})
|
|
|
|
It("bad conn check", func() {
|
|
Expect(conn.Close()).NotTo(HaveOccurred())
|
|
Expect(connCheck(conn)).To(HaveOccurred())
|
|
})
|
|
|
|
It("check conn deadline", func() {
|
|
Expect(conn.SetDeadline(time.Now())).NotTo(HaveOccurred())
|
|
time.Sleep(time.Millisecond * 10)
|
|
Expect(connCheck(conn)).NotTo(HaveOccurred())
|
|
Expect(conn.Close()).NotTo(HaveOccurred())
|
|
})
|
|
})
|