| func (t *transport) RoundTrip(req *http.Request) (rsp *http.Response, err error) { |
| var authContainer *AuthContainer |
| headers := make(http.Header) |
| headers.Add("Content-Type", "application/xml; charset=UTF-8") |
| body := ioutil.NopCloser(strings.NewReader(t.response)) |
| if (t.status < 200) || (299 < t.status) { |
| Status: fmt.Sprintf("%d %s", t.status, statusMsg), |
| bytes, err := ioutil.ReadAll(req.Body) |
| err = json.Unmarshal(bytes, &authContainer) |
| t.tenantIdFound = (authContainer.Auth.TenantId != "") |
| if t.tenantIdFound != t.expectTenantId { |
| rsp.Status = "500 Internal Server Error" |
| func newTransport() *transport { |
| func (t *transport) IgnoreTenantId() *transport { |
| func (t *transport) ExpectTenantId() *transport { |
| func (t *transport) WithResponse(r string) *transport { |
| func (t *transport) WithError(code int) *transport { |
| t.response = fmt.Sprintf("Error %d", code) |
| func (t *transport) VerifyCalls(test *testing.T, n int) error { |
| err := fmt.Errorf("Expected Transport to be called %d times; found %d instead", n, t.called) |