Documentation ¶
Index ¶
- func NewRequest() *http.Request
- func NewRequestWithContent(c string) *http.Request
- func NewResponse() *http.Response
- func NewResponseWithBodyAndStatus(body *Body, c int, s string) *http.Response
- func NewResponseWithContent(c string) *http.Response
- func NewResponseWithStatus(s string, c int) *http.Response
- func SetResponseHeaderValues(resp *http.Response, h string, values []string)
- type Body
- type FakeCredential
- type MockSender
- func (c *MockSender) AppendAndRepeatResponse(resp *http.Response, repeat int)
- func (c *MockSender) AppendResponse(resp *http.Response)
- func (c *MockSender) Attempts() int
- func (s *MockSender) Do(req *http.Request) (resp *http.Response, err error)
- func (c *MockSender) NumResponses() int
- func (c *MockSender) SetAndRepeatError(err error, repeat int)
- func (c *MockSender) SetError(err error)
- type RequestRecorderPolicy
- type Senders
- type SerialSender
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewRequestWithContent ¶
NewRequestWithContent instantiates a new request using the passed string for the body content.
func NewResponseWithBodyAndStatus ¶
NewResponseWithBodyAndStatus instantiates a new response using the specified mock body, status and status code
func NewResponseWithContent ¶
NewResponseWithContent instantiates a new response with the passed string as the body content.
func NewResponseWithStatus ¶
NewResponseWithStatus instantiates a new response using the passed string and integer as the status and status code.
Types ¶
type Body ¶
type Body struct {
// contains filtered or unexported fields
}
Body implements acceptable body over a string.
type FakeCredential ¶
type FakeCredential struct{}
FakeCredential is a credential that returns a fake token.
func (*FakeCredential) GetToken ¶
func (c *FakeCredential) GetToken(ctx context.Context, opts policy.TokenRequestOptions) (azcore.AccessToken, error)
type MockSender ¶
type MockSender struct { // PathPattern, if non-empty, is assumed to be a regular expression // that must match the request path. PathPattern string // contains filtered or unexported fields }
MockSender provides a mechanism to test requests and provide responses to/from the Azure cloud API.
func NewSenderWithValue ¶
func NewSenderWithValue(v interface{}) *MockSender
NewSenderWithValue returns a *mocks.Sender that marshals the provided object to JSON and sets it as the content. This function will panic if marshalling fails.
func (*MockSender) AppendAndRepeatResponse ¶
func (c *MockSender) AppendAndRepeatResponse(resp *http.Response, repeat int)
AppendAndRepeatResponse adds the passed http.Response to the response stack along with a repeat count. A negative repeat count will return the response for all remaining calls to Do.
func (*MockSender) AppendResponse ¶
func (c *MockSender) AppendResponse(resp *http.Response)
AppendResponse adds the passed http.Response to the response stack.
func (*MockSender) Attempts ¶
func (c *MockSender) Attempts() int
Attempts returns the number of times Do was called.
func (*MockSender) NumResponses ¶
func (c *MockSender) NumResponses() int
NumResponses returns the number of responses that have been added to the sender.
func (*MockSender) SetAndRepeatError ¶
func (c *MockSender) SetAndRepeatError(err error, repeat int)
SetAndRepeatError sets the error Do should return and how many calls to Do will return the error. A negative repeat value will return the error for all remaining calls to Do.
func (*MockSender) SetError ¶
func (c *MockSender) SetError(err error)
SetError sets the error Do should return.
type RequestRecorderPolicy ¶
type Senders ¶
type Senders []policy.Transporter
Senders is a Sender that includes a collection of Senders, which will be called in sequence.
type SerialSender ¶
type SerialSender struct {
// contains filtered or unexported fields
}
SerialSender is a Sender that permits only one active Do call at a time.
func NewSerialSender ¶
func NewSerialSender(s policy.Transporter) *SerialSender