File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -148,6 +148,31 @@ func TestFraming(t *testing.T) {
148148 }
149149}
150150
151+ func TestConcurrencyWriteControl (t * testing.T ) {
152+ const message = "this is a ping/pong messsage"
153+ loop := 10
154+ workers := 10
155+ for i := 0 ; i < loop ; i ++ {
156+ var connBuf bytes.Buffer
157+
158+ wg := sync.WaitGroup {}
159+ wc := newTestConn (nil , & connBuf , true )
160+
161+ for i := 0 ; i < workers ; i ++ {
162+ wg .Add (1 )
163+ go func () {
164+ defer wg .Done ()
165+ if err := wc .WriteControl (PongMessage , []byte (message ), time .Now ().Add (time .Second )); err != nil {
166+ t .Errorf ("concurrently wc.WriteControl() returned %v" , err )
167+ }
168+ }()
169+ }
170+
171+ wg .Wait ()
172+ wc .Close ()
173+ }
174+ }
175+
151176func TestControl (t * testing.T ) {
152177 const message = "this is a ping/pong message"
153178 for _ , isServer := range []bool {true , false } {
You can’t perform that action at this time.
0 commit comments