(c *C)
| 22 | var _ = Suite(&SimplePoolSuite{}) |
| 23 | |
| 24 | func (s *SimplePoolSuite) TestHTTP(c *C) { |
| 25 | server, addr := test_utils.SetupTestServer(false) |
| 26 | defer server.Close() |
| 27 | |
| 28 | // do single request |
| 29 | params := ConnectionParams{ |
| 30 | MaxIdle: 1, |
| 31 | } |
| 32 | var pool Pool = NewSimplePool(addr, params) |
| 33 | |
| 34 | // do 10 requests concurrently |
| 35 | origMaxProcs := runtime.GOMAXPROCS(runtime.NumCPU()) |
| 36 | defer func() { runtime.GOMAXPROCS(origMaxProcs) }() |
| 37 | |
| 38 | const count = 10 |
| 39 | finished := make(chan bool) |
| 40 | for i := 0; i < count; i++ { |
| 41 | go func() { |
| 42 | req, err := http.NewRequest("GET", "/", nil) |
| 43 | c.Assert(err, IsNil) |
| 44 | |
| 45 | _, err = pool.Do(req) |
| 46 | c.Assert(err, IsNil) |
| 47 | finished <- true |
| 48 | }() |
| 49 | } |
| 50 | |
| 51 | for i := 0; i < count; i++ { |
| 52 | select { |
| 53 | case <-finished: |
| 54 | // cool |
| 55 | |
| 56 | case <-time.After(5 * time.Second): |
| 57 | c.FailNow() |
| 58 | } |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | func (s *SimplePoolSuite) TestConnectTimeout(c *C) { |
| 63 | server, addr := test_utils.SetupTestServer(false) |
nothing calls this directly
no test coverage detected