File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -791,21 +791,32 @@ func TestUtube_Put(t *testing.T) {
791791 close (errChan )
792792 }()
793793
794- time .Sleep (100 * time .Millisecond )
794+ time .Sleep (500 * time .Millisecond )
795795 // the queue should be blocked for ~2 seconds
796796 start := time .Now ()
797797 t2 , err := q .TakeTimeout (2 * time .Second )
798798 if err != nil {
799+ <- errChan
799800 t .Fatalf ("Failed to take task from utube: %s" , err )
800801 }
802+
803+ if t2 == nil {
804+ <- errChan
805+ t .Fatalf ("Got nil task" )
806+ }
807+
801808 if err := t2 .Ack (); err != nil {
809+ <- errChan
802810 t .Fatalf ("Failed to ack task: %s" , err )
803811 }
804812 end := time .Now ()
805813 if _ , ok := <- errChan ; ok {
806814 t .Fatalf ("One of tasks failed" )
807815 }
808- if math .Abs (float64 (end .Sub (start )- 2 * time .Second )) > float64 (200 * time .Millisecond ) {
816+
817+ timeSpent := math .Abs (float64 (end .Sub (start ) - 2 * time .Second ))
818+
819+ if timeSpent > float64 (700 * time .Millisecond ) {
809820 t .Fatalf ("Blocking time is less than expected: actual = %.2fs, expected = 1s" , end .Sub (start ).Seconds ())
810821 }
811822}
You can’t perform that action at this time.
0 commit comments