(t *testing.T)
| 112 | } |
| 113 | |
| 114 | func TestFactory_SubscribeReloadEventFrom(t *testing.T) { |
| 115 | t.Parallel() |
| 116 | |
| 117 | closed := make(chan struct{}) |
| 118 | ctx, cancel := context.WithCancel(context.Background()) |
| 119 | defer cancel() |
| 120 | f := NewFactory(func(_ string) (Pair, error) { |
| 121 | return Pair{ |
| 122 | Conn: &struct{}{}, |
| 123 | Closer: func() { close(closed) }, |
| 124 | }, nil |
| 125 | }) |
| 126 | dispatcher := events.SyncDispatcher{} |
| 127 | f.SubscribeReloadEventFrom(&dispatcher) |
| 128 | |
| 129 | f.Make("default") |
| 130 | _ = dispatcher.Dispatch(ctx, events.OnReload, events.OnReloadPayload{}) |
| 131 | |
| 132 | select { |
| 133 | case <-closed: |
| 134 | case <-time.After(4 * time.Second): |
| 135 | t.Fatalf("foo should be closed by now") |
| 136 | } |
| 137 | } |
| 138 | |
| 139 | func BenchmarkFactory_slowConn(b *testing.B) { |
| 140 | f := NewFactory(func(name string) (Pair, error) { |
nothing calls this directly
no test coverage detected