main_test.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. //go:build windows
  2. package yu_proxy_pool
  3. import (
  4. "fmt"
  5. yu_proxy "gogs.qqck.cn/s/tools/proxy"
  6. yu_rand "gogs.qqck.cn/s/tools/rand"
  7. "testing"
  8. "time"
  9. )
  10. func TestPool_GetCheck(t *testing.T) {
  11. j_pool := New().SetGetMax(10)
  12. j_pool.SetUrl("http://api.hailiangip.com:8422/api/getIp?type=1&num=10&pid=17&unbindTime=60&cid=-1&orderId=O23110418445724522113&time=1699772813&sign=44ab2df7bb4157420ddfa72e6394e7b7&noDuplicate=0&dataType=1&lineSeparator=0")
  13. for i := 0; i < 5; i++ {
  14. go func() {
  15. time.Sleep(time.Millisecond * time.Duration(yu_rand.Int31n(1000)))
  16. fmt.Println(j_pool.GetCheck(func(info *yu_proxy.Info) bool {
  17. fmt.Println("GetCheck")
  18. return true
  19. }))
  20. }()
  21. }
  22. time.Sleep(time.Second * 5)
  23. }
  24. func TestPool_GetCheckEx(t *testing.T) {
  25. j_pool := New().SetGetMax(10)
  26. j_pool.SetUrl("http://api.hailiangip.com:8422/api/getIp?type=1&num=10&pid=17&unbindTime=60&cid=-1&orderId=O23110418445724522113&time=1699772813&sign=44ab2df7bb4157420ddfa72e6394e7b7&noDuplicate=0&dataType=1&lineSeparator=0")
  27. for i := 0; i < 5; i++ {
  28. go func() {
  29. time.Sleep(time.Millisecond * time.Duration(yu_rand.Int31n(1000)))
  30. fmt.Println(j_pool.GetCheckEx(func(info *yu_proxy.Info) bool {
  31. fmt.Println("GetCheckEx")
  32. return true
  33. }))
  34. }()
  35. }
  36. time.Sleep(time.Second * 5)
  37. }