github.com/damirazo/docker@v1.9.0/integration-cli/docker_api_events_test.go (about)

     1  package main
     2  
     3  import (
     4  	"net/http"
     5  	"time"
     6  
     7  	"github.com/go-check/check"
     8  )
     9  
    10  func (s *DockerSuite) TestEventsApiEmptyOutput(c *check.C) {
    11  	type apiResp struct {
    12  		resp *http.Response
    13  		err  error
    14  	}
    15  	chResp := make(chan *apiResp)
    16  	go func() {
    17  		resp, body, err := sockRequestRaw("GET", "/events", nil, "")
    18  		body.Close()
    19  		chResp <- &apiResp{resp, err}
    20  	}()
    21  
    22  	select {
    23  	case r := <-chResp:
    24  		c.Assert(r.err, check.IsNil)
    25  		c.Assert(r.resp.StatusCode, check.Equals, http.StatusOK)
    26  	case <-time.After(3 * time.Second):
    27  		c.Fatal("timeout waiting for events api to respond, should have responded immediately")
    28  	}
    29  }