MCPcopy Create free account
hub / github.com/godbus/dbus / TestSequentialHandler_RemoveOneChannelOfMany

Function TestSequentialHandler_RemoveOneChannelOfMany

sequential_handler_test.go:87–118  ·  view source on GitHub ↗

Test that removing one channel results in no more messages being written to that channel, and the other channels are unaffected.

(t *testing.T)

Source from the content-addressed store, hash-verified

85// Test that removing one channel results in no more messages being
86// written to that channel, and the other channels are unaffected.
87func 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.
121func TestSequentialHandler_TerminateClosesAllChannels(t *testing.T) {

Callers

nothing calls this directly

Calls 7

writeSignalsFunction · 0.85
countSignalsFunction · 0.85
readSignalsFunction · 0.85
AddSignalMethod · 0.65
RemoveSignalMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…