~abp998/gwacl/subscription

« back to all changes in this revision

Viewing changes to testing_test.go

  • Committer: Raphael Badin
  • Date: 2013-06-27 10:55:35 UTC
  • mto: This revision was merged to the branch mainline in revision 141.
  • Revision ID: raphael.badin@canonical.com-20130627105535-4mhip5fxl22jwwdw
Expose testing utility.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
    _, err := context.ListContainers(request)
24
24
    c.Check(err, ErrorMatches, ".*"+errorMessage+".*")
25
25
}
 
26
 
 
27
func (suite *testTesting) TestNewDispatcherResponse(c *C) {
 
28
    body := []byte("test body")
 
29
    statusCode := http.StatusOK
 
30
    errorObject := fmt.Errorf("canned-error")
 
31
    dispatcherResponse := NewDispatcherResponse(body, statusCode, errorObject)
 
32
    c.Check(dispatcherResponse.errorObject, Equals, errorObject)
 
33
    c.Check(dispatcherResponse.response.Body, DeepEquals, body)
 
34
    c.Check(dispatcherResponse.response.StatusCode, Equals, statusCode)
 
35
}
 
36
 
 
37
func (suite *testTesting) TestPatchManagementAPIResponses(c *C) {
 
38
   response := NewDispatcherResponse([]byte("<Images></Images>"), http.StatusOK, nil)
 
39
   responses := []DispatcherResponse{response, response}
 
40
   requests := PatchManagementAPIResponses(responses)
 
41
   api := makeAPI(c)
 
42
   _, err := api.ListOSImages()
 
43
   c.Assert(err, IsNil)
 
44
   _, err = api.ListOSImages()
 
45
   c.Assert(err, IsNil)
 
46
   c.Assert(len(*requests), Equals, 2)
 
47
   c.Check((*requests)[0].URL, Equals, api.session.composeURL("services/images"))
 
48
   c.Check((*requests)[1].URL, Equals, api.session.composeURL("services/images"))
 
49
}
 
50