Test that removing one channel results in no more messages being written to that channel, and the other channels are unaffected.
(t *testing.T)
| 85 | // Test that removing one channel results in no more messages being |
| 86 | // written to that channel, and the other channels are unaffected. |
| 87 | func TestSequentialHandler_RemoveOneChannelOfMany(t *testing.T) { |
| 88 | t.Parallel() |
| 89 | handler := NewSequentialSignalHandler() |
| 90 | |
| 91 | channelOne := make(chan *Signal) |
| 92 | handler.(SignalRegistrar).AddSignal(channelOne) |
| 93 | |
| 94 | channelTwo := make(chan *Signal, 10) |
| 95 | handler.(SignalRegistrar).AddSignal(channelTwo) |
| 96 | |
| 97 | channelThree := make(chan *Signal, 2) |
| 98 | handler.(SignalRegistrar).AddSignal(channelThree) |
| 99 | |
| 100 | writeSignals(handler, 1000) |
| 101 | |
| 102 | handler.(SignalRegistrar).RemoveSignal(channelTwo) |
| 103 | defer close(channelTwo) |
| 104 | |
| 105 | count, closed := countSignals(channelTwo) |
| 106 | if count > 10 { |
| 107 | t.Error("handler continued writing to channel after removal") |
| 108 | } |
| 109 | if closed { |
| 110 | t.Error("handler closed channel on .RemoveChannel()") |
| 111 | } |
| 112 | |
| 113 | // Check that closing channel two does not close channel one. |
| 114 | readSignals(t, channelOne) |
| 115 | |
| 116 | // Check that closing channel two does not close channel three. |
| 117 | readSignals(t, channelThree) |
| 118 | } |
| 119 | |
| 120 | // Test that Terminate() closes all channels that were attached at the time. |
| 121 | func TestSequentialHandler_TerminateClosesAllChannels(t *testing.T) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…