@@ -13,7 +13,7 @@ type NSQSuite struct{}
13
13
14
14
var nsqSuite = Suite (& NSQSuite {})
15
15
16
- func (s * NSQSuite ) TestToFromNSQ (c * C ) {
16
+ func (s * NSQSuite ) TestToNSQ (c * C ) {
17
17
log .Println ("testing toNSQ" )
18
18
19
19
toB , toC := test_utils .NewBlock ("testingToNSQ" , "tonsq" )
@@ -28,6 +28,9 @@ func (s *NSQSuite) TestToFromNSQ(c *C) {
28
28
toC .QueryChan <- & blocks.QueryMsg {MsgChan : toQueryChan , Route : "rule" }
29
29
})
30
30
31
+ outChan := make (chan * blocks.Msg )
32
+ toC .AddChan <- & blocks.AddChanMsg {Route : "1" , Channel : outChan }
33
+
31
34
time .AfterFunc (time .Duration (2 )* time .Second , func () {
32
35
nsqMsg := map [string ]interface {}{"Foo" : "Bar" }
33
36
postData := & blocks.Msg {Msg : nsqMsg , Route : "in" }
@@ -38,6 +41,25 @@ func (s *NSQSuite) TestToFromNSQ(c *C) {
38
41
toC .QuitChan <- true
39
42
})
40
43
44
+ for {
45
+ select {
46
+ case messageI := <- toQueryChan :
47
+ c .Assert (messageI , DeepEquals , ruleMsg )
48
+
49
+ case message := <- outChan :
50
+ log .Println ("printing message from outChan:" , message )
51
+
52
+ case err := <- toC .ErrChan :
53
+ if err != nil {
54
+ c .Errorf (err .Error ())
55
+ } else {
56
+ return
57
+ }
58
+ }
59
+ }
60
+ }
61
+
62
+ func (s * NSQSuite ) TestFromNSQ (c * C ) {
41
63
log .Println ("testing fromNSQ" )
42
64
43
65
fromB , fromC := test_utils .NewBlock ("testingfromNSQ" , "fromnsq" )
@@ -65,18 +87,9 @@ func (s *NSQSuite) TestToFromNSQ(c *C) {
65
87
case messageI := <- fromQueryChan :
66
88
c .Assert (messageI , DeepEquals , nsqSetup )
67
89
68
- case messageI := <- toQueryChan :
69
- c .Assert (messageI , DeepEquals , ruleMsg )
70
-
71
90
case message := <- outChan :
72
91
log .Println ("printing message from outChan:" , message )
73
92
74
- case err := <- toC .ErrChan :
75
- if err != nil {
76
- c .Errorf (err .Error ())
77
- } else {
78
- return
79
- }
80
93
case err := <- fromC .ErrChan :
81
94
if err != nil {
82
95
c .Errorf (err .Error ())
0 commit comments