11func TestLifecycle(t *testing.T) {
12 Shutdown, ShutdownCancel = context.WithCancel(context.Background())
13 nc0, nc1 := net.Pipe()
16 Connections.Register(nc0, "proto", "listener")
17 Connections.Shutdown()
19 done := Connections.Done()
22 t.Fatalf("already done, but still a connection open")
26 _, err := nc0.Read(make([]byte, 1))
28 t.Fatalf("expected i/o deadline exceeded, got no error")
30 if !errors.Is(err, os.ErrDeadlineExceeded) {
31 t.Fatalf("got %v, expected os.ErrDeadlineExceeded", err)
33 Connections.Unregister(nc0)
37 t.Fatalf("unregistered connection, but not yet done")