@@ -40,6 +40,24 @@ func Test_Connectable_IterableChannel_Composed(t *testing.T) {
4040 testConnectableComposed (t , obs )
4141}
4242
43+ func Test_Connectable_IterableChannel_Disposed (t * testing.T ) {
44+ ch := make (chan Item , 10 )
45+ go func () {
46+ ch <- Of (1 )
47+ ch <- Of (2 )
48+ ch <- Of (3 )
49+ close (ch )
50+ }()
51+ obs := & ObservableImpl {
52+ iterable : newChannelIterable (ch , WithPublishStrategy ()),
53+ }
54+ obs .Connect ()()
55+ ctx , cancel := context .WithTimeout (context .Background (), 50 * time .Millisecond )
56+ defer cancel ()
57+ time .Sleep (50 * time .Millisecond )
58+ Assert (ctx , t , obs , IsEmpty ())
59+ }
60+
4361func Test_Connectable_IterableChannel_WithoutConnect (t * testing.T ) {
4462 ch := make (chan Item , 10 )
4563 go func () {
@@ -82,6 +100,24 @@ func Test_Connectable_IterableCreate_Composed(t *testing.T) {
82100 testConnectableComposed (t , obs )
83101}
84102
103+ func Test_Connectable_IterableCreate_Disposed (t * testing.T ) {
104+ ctx , cancel := context .WithCancel (context .Background ())
105+ defer cancel ()
106+ obs := & ObservableImpl {
107+ iterable : newCreateIterable ([]Producer {func (_ context.Context , ch chan <- Item ) {
108+ ch <- Of (1 )
109+ ch <- Of (2 )
110+ ch <- Of (3 )
111+ cancel ()
112+ }}, WithPublishStrategy (), WithContext (ctx )),
113+ }
114+ obs .Connect ()()
115+ ctx , cancel = context .WithTimeout (context .Background (), 550 * time .Millisecond )
116+ defer cancel ()
117+ time .Sleep (50 * time .Millisecond )
118+ Assert (ctx , t , obs , IsEmpty ())
119+ }
120+
85121func Test_Connectable_IterableCreate_WithoutConnect (t * testing.T ) {
86122 ctx , cancel := context .WithCancel (context .Background ())
87123 defer cancel ()
0 commit comments