I am trying to unit test an API which returns a CSV response. I am used to testing APIs that return Json response by doing something like this :
resBody := `{"access_token": "token","instance_url": "url","id": "id","token_type": "Bearer"}`
r := ioutil.NopCloser(bytes.NewReader([]byte(resBody)))
clientMock.GetMock = func(url string) (*http.Response, error) {
return &http.Response{
StatusCode: 200,
Body: r,
}, nil
}
Here, the resBody is my mocked Json response, however unable to figure out what would be an equivalent response structure for testing APIs that return csv response.