@@ -31,6 +31,10 @@ func (m mockMessage) Bytes() []byte {
3131 return []byte (m .Message )
3232}
3333
34+ func (m mockMessage ) Payload () []byte {
35+ return []byte (m .Message )
36+ }
37+
3438func TestNSQDefaultFlow (t * testing.T ) {
3539 m := & mockMessage {
3640 Message : "foo" ,
@@ -80,7 +84,7 @@ func TestNSQCustomFuncAndWait(t *testing.T) {
8084 WithAddr (host + ":4150" ),
8185 WithTopic ("test3" ),
8286 WithMaxInFlight (10 ),
83- WithRunFunc (func (ctx context.Context , m core.QueuedMessage ) error {
87+ WithRunFunc (func (ctx context.Context , m core.TaskMessage ) error {
8488 time .Sleep (500 * time .Millisecond )
8589 return nil
8690 }),
@@ -131,7 +135,7 @@ func TestJobReachTimeout(t *testing.T) {
131135 WithAddr (host + ":4150" ),
132136 WithTopic ("timeout" ),
133137 WithMaxInFlight (2 ),
134- WithRunFunc (func (ctx context.Context , m core.QueuedMessage ) error {
138+ WithRunFunc (func (ctx context.Context , m core.TaskMessage ) error {
135139 for {
136140 select {
137141 case <- ctx .Done ():
@@ -155,7 +159,9 @@ func TestJobReachTimeout(t *testing.T) {
155159 assert .NoError (t , err )
156160 q .Start ()
157161 time .Sleep (400 * time .Millisecond )
158- assert .NoError (t , q .Queue (m , job .WithTimeout (20 * time .Millisecond )))
162+ assert .NoError (t , q .Queue (m , job.AllowOption {
163+ Timeout : job .Time (20 * time .Millisecond ),
164+ }))
159165 time .Sleep (2 * time .Second )
160166 q .Release ()
161167}
@@ -168,7 +174,7 @@ func TestCancelJobAfterShutdown(t *testing.T) {
168174 WithAddr (host + ":4150" ),
169175 WithTopic ("cancel" ),
170176 WithLogger (queue .NewLogger ()),
171- WithRunFunc (func (ctx context.Context , m core.QueuedMessage ) error {
177+ WithRunFunc (func (ctx context.Context , m core.TaskMessage ) error {
172178 for {
173179 select {
174180 case <- ctx .Done ():
@@ -192,7 +198,9 @@ func TestCancelJobAfterShutdown(t *testing.T) {
192198 assert .NoError (t , err )
193199 q .Start ()
194200 time .Sleep (400 * time .Millisecond )
195- assert .NoError (t , q .Queue (m , job .WithTimeout (3 * time .Second )))
201+ assert .NoError (t , q .Queue (m , job.AllowOption {
202+ Timeout : job .Time (3 * time .Second ),
203+ }))
196204 time .Sleep (2 * time .Second )
197205 q .Release ()
198206}
@@ -205,7 +213,7 @@ func TestGoroutineLeak(t *testing.T) {
205213 WithAddr (host + ":4150" ),
206214 WithTopic ("GoroutineLeak" ),
207215 WithLogger (queue .NewEmptyLogger ()),
208- WithRunFunc (func (ctx context.Context , m core.QueuedMessage ) error {
216+ WithRunFunc (func (ctx context.Context , m core.TaskMessage ) error {
209217 for {
210218 select {
211219 case <- ctx .Done ():
@@ -249,7 +257,7 @@ func TestGoroutinePanic(t *testing.T) {
249257 w := NewWorker (
250258 WithAddr (host + ":4150" ),
251259 WithTopic ("GoroutinePanic" ),
252- WithRunFunc (func (ctx context.Context , m core.QueuedMessage ) error {
260+ WithRunFunc (func (ctx context.Context , m core.TaskMessage ) error {
253261 panic ("missing something" )
254262 }),
255263 )
@@ -275,7 +283,7 @@ func TestNSQStatsinQueue(t *testing.T) {
275283 w := NewWorker (
276284 WithAddr (host + ":4150" ),
277285 WithTopic ("nsq_stats" ),
278- WithRunFunc (func (ctx context.Context , m core.QueuedMessage ) error {
286+ WithRunFunc (func (ctx context.Context , m core.TaskMessage ) error {
279287 log .Println ("get message" )
280288 return nil
281289 }),
0 commit comments