github.com/MeteorsLiu/simpleMQ@v1.0.3/router/router_test.go (about) 1 package router 2 3 import ( 4 "fmt" 5 "strconv" 6 "testing" 7 "time" 8 9 "github.com/MeteorsLiu/simpleMQ/queue" 10 ) 11 12 func TestRouter(t *testing.T) { 13 r := NewRouter() 14 15 for i := 0; i < 5; i++ { 16 i := i 17 r.DispatchTask(queue.NewTask(func() error { 18 t.Log(i) 19 return fmt.Errorf("test" + strconv.Itoa(i)) 20 }, queue.WithNoRetryFunc())) 21 } 22 time.Sleep(10 * time.Second) 23 } 24 25 func TestRouterPath(t *testing.T) { 26 r := NewRouter() 27 28 for i := 0; i < 5; i++ { 29 i := i 30 r.DispatchPathTask("/red", queue.NewTask(func() error { 31 t.Log(i) 32 return fmt.Errorf("test-red" + strconv.Itoa(i)) 33 }, queue.WithNoRetryFunc())) 34 } 35 time.Sleep(2 * time.Minute) 36 }