github.com/pf-qiu/concourse/v6@v6.7.3-0.20201207032516-1f455d73275f/atc/worker/gclient/connection/connection_suite_test.go (about) 1 package connection_test 2 3 import ( 4 "net" 5 "sync" 6 7 . "github.com/onsi/ginkgo" 8 . "github.com/onsi/gomega" 9 10 "testing" 11 ) 12 13 func TestConnection(t *testing.T) { 14 RegisterFailHandler(Fail) 15 RunSpecs(t, "Connection Suite") 16 } 17 18 func uint64ptr(n uint64) *uint64 { 19 return &n 20 } 21 22 type wrappedConnection struct { 23 net.Conn 24 25 mu sync.Mutex 26 closed bool 27 } 28 29 func (wc *wrappedConnection) isClosed() bool { 30 wc.mu.Lock() 31 defer wc.mu.Unlock() 32 33 return wc.closed 34 } 35 36 func (wc *wrappedConnection) Close() error { 37 err := wc.Conn.Close() 38 39 wc.mu.Lock() 40 defer wc.mu.Unlock() 41 if err == nil { 42 wc.closed = true 43 } 44 return err 45 }