5538: update the test to set resp.body with the given string from stub than hard...
authorradhika <radhika@curoverse.com>
Sat, 7 Nov 2015 14:25:48 +0000 (09:25 -0500)
committerradhika <radhika@curoverse.com>
Sat, 7 Nov 2015 14:25:48 +0000 (09:25 -0500)
sdk/go/arvadosclient/arvadosclient_test.go

index bc88c4402273dae3770e8edc514d3d101edc59b9..3746ad0ee26eee45bda09771d5aed48b0179d9b6 100644 (file)
@@ -250,18 +250,6 @@ func RunFakeArvadosServer(st http.Handler) (api APIServer, err error) {
        return
 }
 
-func (h *APIStub) ServeHTTP(resp http.ResponseWriter, req *http.Request) {
-       resp.WriteHeader(h.respStatus[h.count])
-
-       if h.respStatus[h.count] == 200 {
-               resp.Write([]byte(`{"ok":"ok"}`))
-       } else {
-               resp.Write([]byte(``))
-       }
-
-       h.count++
-}
-
 type APIStub struct {
        method       string
        count        int
@@ -270,6 +258,12 @@ type APIStub struct {
        responseBody []string
 }
 
+func (h *APIStub) ServeHTTP(resp http.ResponseWriter, req *http.Request) {
+       resp.WriteHeader(h.respStatus[h.count])
+       resp.Write([]byte(h.responseBody[h.count]))
+       h.count++
+}
+
 func (s *MockArvadosServerSuite) TestWithRetries(c *C) {
        for _, stub := range []APIStub{
                {