10 "github.com/prometheus/client_golang/prometheus"
13func TestLifecycle(t *testing.T) {
14 Shutdown, ShutdownCancel = context.WithCancel(context.Background())
16 conns: map[net.Conn]connKind{},
17 gauges: map[connKind]prometheus.GaugeFunc{},
18 active: map[connKind]int64{},
20 nc0, nc1 := net.Pipe()
23 c.Register(nc0, "proto", "listener")
29 t.Fatalf("already done, but still a connection open")
33 _, err := nc0.Read(make([]byte, 1))
35 t.Fatalf("expected i/o deadline exceeded, got no error")
37 if !errors.Is(err, os.ErrDeadlineExceeded) {
38 t.Fatalf("got %v, expected os.ErrDeadlineExceeded", err)
44 t.Fatalf("unregistered connection, but not yet done")