map[string]string{"xxxx": server.URL},
map[string]string{})
- SendTrashLists("", &kc, tl)
+ err := SendTrashLists("", &kc, tl)
server.Close()
+ c.Check(err, IsNil)
+
c.Check(th.request,
DeepEquals,
tl[server.URL])
}
func (this *TestHandlerError) ServeHTTP(writer http.ResponseWriter, req *http.Request) {
- http.Error(writer, "I'm a teapot", 405)
+ http.Error(writer, "I'm a teapot", 418)
}
-func (s *KeepSuite) TestSendTrashListError(c *C) {
- // Server responds with an error
-
- th := TestHandlerError{}
- server := httptest.NewServer(&th)
-
+func sendTrashListError(c *C, server *httptest.Server) {
tl := map[string]TrashList{
server.URL: TrashList{TrashRequest{"000000000000000000000000deadbeef", 99}}}
map[string]string{"xxxx": server.URL},
map[string]string{})
- SendTrashLists("", &kc, tl)
- server.Close()
-}
-
-func (s *KeepSuite) TestSendTrashListError2(c *C) {
- // Server is not reachable
+ err := SendTrashLists("", &kc, tl)
- th := TestHandler{}
- server := httptest.NewServer(&th)
- server.Close()
-
- tl := map[string]TrashList{
- server.URL: TrashList{TrashRequest{"000000000000000000000000deadbeef", 99}}}
+ c.Check(err, NotNil)
+ c.Check(err[0], NotNil)
+}
- kc := keepclient.KeepClient{Client: &http.Client{}}
- kc.SetServiceRoots(map[string]string{"xxxx": server.URL},
- map[string]string{"xxxx": server.URL},
- map[string]string{})
+func (s *KeepSuite) TestSendTrashListErrorResponse(c *C) {
+ sendTrashListError(c, httptest.NewServer(&TestHandlerError{}))
+}
- SendTrashLists("", &kc, tl)
+func (s *KeepSuite) TestSendTrashListUnreachable(c *C) {
+ sendTrashListError(c, httptest.NewUnstartedServer(&TestHandler{}))
}