We need a function to construct the response instead of simply declaring it as a variable since the response body will be consumed by the credentials, and therefore we will need a new one everytime.
()
| 116 | // as a variable since the response body will be consumed by the |
| 117 | // credentials, and therefore we will need a new one everytime. |
| 118 | func makeGoodResponse() *http.Response { |
| 119 | respJSON, _ := json.Marshal(responseParameters{ |
| 120 | AccessToken: accessTokenContents, |
| 121 | IssuedTokenType: "urn:ietf:params:oauth:token-type:access_token", |
| 122 | TokenType: "Bearer", |
| 123 | ExpiresIn: 3600, |
| 124 | }) |
| 125 | respBody := io.NopCloser(bytes.NewReader(respJSON)) |
| 126 | return &http.Response{ |
| 127 | Status: "200 OK", |
| 128 | StatusCode: http.StatusOK, |
| 129 | Body: respBody, |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | // Overrides the http.Client with a fakeClient which sends a good response. |
| 134 | func overrideHTTPClientGood() (*testutils.FakeHTTPClient, func()) { |
no test coverage detected