@@ -2,6 +2,7 @@ package signalr
2
2
3
3
import (
4
4
"context"
5
+ "fmt"
5
6
"time"
6
7
7
8
. "github.com/onsi/ginkgo"
@@ -10,7 +11,8 @@ import (
10
11
11
12
var _ = Describe ("Server.HubClients" , func () {
12
13
Context ("All().Send()" , func () {
13
- It ("should send clients" , func (done Done ) {
14
+ j := 1
15
+ It (fmt .Sprintf ("should send clients %v" , j ), func (done Done ) {
14
16
// Create a simple server
15
17
server , err := NewServer (context .TODO (), SimpleHubFactory (& simpleHub {}),
16
18
testLoggerOption (),
@@ -25,7 +27,7 @@ var _ = Describe("Server.HubClients", func() {
25
27
// Give the server some time. In contrast to the client, we have not connected state to query
26
28
<- time .After (100 * time .Millisecond )
27
29
// Create the Client
28
- receiver := & simpleReceiver {}
30
+ receiver := & simpleReceiver {ch : make ( chan string , 1 ) }
29
31
ctx , cancelClient := context .WithCancel (context .Background ())
30
32
client , _ := NewClient (ctx ,
31
33
WithConnection (cliConn ),
@@ -38,24 +40,16 @@ var _ = Describe("Server.HubClients", func() {
38
40
// Wait for client running
39
41
Expect (<- client .WaitForState (context .Background (), ClientConnected )).NotTo (HaveOccurred ())
40
42
// Send from the server to "all" clients
41
- server .HubClients ().All ().Send ("OnCallback" , "All" )
42
- ch := make (chan string , 1 )
43
- go func () {
44
- for {
45
- if result , ok := receiver .result .Load ().(string ); ok {
46
- ch <- result
47
- close (ch )
48
- break
49
- }
50
- }
51
- }()
43
+ <- time .After (100 * time .Millisecond )
44
+ server .HubClients ().All ().Send ("OnCallback" , fmt .Sprintf ("All%v" , j ))
52
45
// Did the receiver get what we did send?
53
- Expect (<- ch ).To (Equal ("All" ))
46
+ Expect (<- receiver . ch ).To (Equal (fmt . Sprintf ( "All%v" , j ) ))
54
47
cancelClient ()
55
48
server .cancel ()
56
49
close (done )
57
50
}, 1.0 )
58
51
})
52
+
59
53
Context ("Caller()" , func () {
60
54
It ("should return nil" , func () {
61
55
server , _ := NewServer (context .TODO (), SimpleHubFactory (& simpleHub {}),
0 commit comments