File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -351,6 +351,10 @@ func (s *subscription) send(e eventOrComment) bool {
351351//
352352// This should be called only from the Server.run() goroutine.
353353func (s * subscription ) close () {
354+ if s .out == nil {
355+ return
356+ }
357+
354358 close (s .out )
355359 s .out = nil
356360}
Original file line number Diff line number Diff line change 55 "io/ioutil"
66 "net/http"
77 "net/http/httptest"
8+ "sync"
89 "testing"
910 "time"
1011
@@ -53,6 +54,27 @@ func TestNewServerHandlerRespondsAfterClose(t *testing.T) {
5354 }
5455}
5556
57+ func TestServerHandlesLoadsOfPendingTasks (t * testing.T ) {
58+ channel := "test"
59+ server := NewServer ()
60+ httpServer := httptest .NewServer (server .Handler (channel ))
61+ defer httpServer .Close ()
62+
63+ var wg sync.WaitGroup
64+ wg .Add (1 )
65+
66+ go func () {
67+ _ , _ = http .Get (httpServer .URL )
68+ wg .Wait ()
69+ }()
70+
71+ server .Register (channel , & testServerRepository {})
72+ for i := 0 ; i < 1000 ; i ++ {
73+ server .PublishComment ([]string {channel }, "my comment" )
74+ }
75+ wg .Done ()
76+ }
77+
5678func TestServerHandlerReceivesPublishedEvents (t * testing.T ) {
5779 channel := "test"
5880 server := NewServer ()
You can’t perform that action at this time.
0 commit comments