本文整理匯總了Golang中github.com/Azure/azure-sdk-for-go/Godeps/_workspace/src/github.com/Azure/go-autorest/autorest/mocks.NewResponse函數的典型用法代碼示例。如果您正苦於以下問題:Golang NewResponse函數的具體用法?Golang NewResponse怎麽用?Golang NewResponse使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了NewResponse函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestCreateResponderDoesNotModify
func TestCreateResponderDoesNotModify(t *testing.T) {
r1 := mocks.NewResponse()
r2 := mocks.NewResponse()
p := CreateResponder()
err := p.Respond(r1)
if err != nil {
t.Errorf("autorest: CreateResponder failed (%v)", err)
}
if !reflect.DeepEqual(r1, r2) {
t.Errorf("autorest: CreateResponder without decorators modified the response")
}
}
示例2: TestResponseRequiresPollingIgnoresSuccess
func TestResponseRequiresPollingIgnoresSuccess(t *testing.T) {
resp := mocks.NewResponse()
if ResponseRequiresPolling(resp) {
t.Error("autorest: ResponseRequiresPolling did not ignore a successful response")
}
}
示例3: TestResponseRequiresPollingLeavesBodyOpen
func TestResponseRequiresPollingLeavesBodyOpen(t *testing.T) {
resp := mocks.NewResponse()
ResponseRequiresPolling(resp)
if !resp.Body.(*mocks.Body).IsOpen() {
t.Error("autorest: ResponseRequiresPolling closed the responise body while ignoring a successful response")
}
}
示例4: TestExtractHeaderHandlesMissingHeader
func TestExtractHeaderHandlesMissingHeader(t *testing.T) {
var v []string
r := mocks.NewResponse()
if !reflect.DeepEqual(ExtractHeader(mocks.TestHeader, r), v) {
t.Errorf("autorest: ExtractHeader failed to handle a missing header -- expected %v, received %v",
v, ExtractHeader(mocks.TestHeader, r))
}
}
示例5: TestExtractHeaderValueHandlesMissingHeader
func TestExtractHeaderValueHandlesMissingHeader(t *testing.T) {
r := mocks.NewResponse()
v := ""
if ExtractHeaderValue(mocks.TestHeader, r) != v {
t.Errorf("autorest: ExtractHeader failed to retrieve the expected header -- expected [%s]%v, received [%s]%v",
mocks.TestHeader, v, mocks.TestHeader, ExtractHeaderValue(mocks.TestHeader, r))
}
}
示例6: TestByIgnoring
func TestByIgnoring(t *testing.T) {
r := mocks.NewResponse()
Respond(r,
(func() RespondDecorator {
return func(r Responder) Responder {
return ResponderFunc(func(r2 *http.Response) error {
r1 := mocks.NewResponse()
if !reflect.DeepEqual(r1, r2) {
t.Errorf("autorest: ByIgnoring modified the HTTP Response -- received %v, expected %v", r2, r1)
}
return nil
})
}
})(),
ByIgnoring(),
ByClosing())
}
示例7: TestClientIsPollingAllowedIgnoresOk
func TestClientIsPollingAllowedIgnoresOk(t *testing.T) {
c := Client{PollingMode: PollUntilAttempts}
r := mocks.NewResponse()
err := c.IsPollingAllowed(r)
if err != nil {
t.Error("autorest: Client#IsPollingAllowed returned an error for an http.Response that does not require polling")
}
}
示例8: TestByClosingIfErrorDoesNotClosesIfNoErrorOccurs
func TestByClosingIfErrorDoesNotClosesIfNoErrorOccurs(t *testing.T) {
r := mocks.NewResponse()
Respond(r,
ByClosingIfError())
if !r.Body.(*mocks.Body).IsOpen() {
t.Errorf("autorest: ByClosingIfError closed the response body even though no error occurred")
}
}
示例9: TestByClosing
func TestByClosing(t *testing.T) {
r := mocks.NewResponse()
err := Respond(r, ByClosing())
if err != nil {
t.Errorf("autorest: ByClosing failed (%v)", err)
}
if r.Body.(*mocks.Body).IsOpen() {
t.Errorf("autorest: ByClosing did not close the response body")
}
}
示例10: TestExtractRequestID
func TestExtractRequestID(t *testing.T) {
uuid := "71FDB9F4-5E49-4C12-B266-DE7B4FD999A6"
resp := mocks.NewResponse()
mocks.SetResponseHeader(resp, HeaderRequestID, uuid)
if ExtractRequestID(resp) != uuid {
t.Errorf("azure: ExtractRequestID failed to extract the %s -- expected %s, received %s",
HeaderRequestID, uuid, ExtractRequestID(resp))
}
}
示例11: TestResponseGetPollingLocation
func TestResponseGetPollingLocation(t *testing.T) {
r := mocks.NewResponse()
mocks.SetLocationHeader(r, mocks.TestURL)
ar := Response{Response: r}
if ar.GetPollingLocation() != mocks.TestURL {
t.Errorf("autorest: Response#GetPollingLocation failed to return correct URL -- expected %v, received %v",
mocks.TestURL, ar.GetPollingLocation())
}
}
示例12: TestExtractHeader
func TestExtractHeader(t *testing.T) {
r := mocks.NewResponse()
v := []string{"v1", "v2", "v3"}
mocks.SetResponseHeaderValues(r, mocks.TestHeader, v)
if !reflect.DeepEqual(ExtractHeader(mocks.TestHeader, r), v) {
t.Errorf("autorest: ExtractHeader failed to retrieve the expected header -- expected [%s]%v, received [%s]%v",
mocks.TestHeader, v, mocks.TestHeader, ExtractHeader(mocks.TestHeader, r))
}
}
示例13: TestResponseGetPollingDelayReturnsDefault
func TestResponseGetPollingDelayReturnsDefault(t *testing.T) {
ar := Response{Response: mocks.NewResponse()}
d1 := 10 * time.Second
d2 := ar.GetPollingDelay(d1)
if d1 != d2 {
t.Errorf("autorest: Response#GetPollingDelay failed to return the default delay -- expected %v, received %v",
d1, d2)
}
}
示例14: TestExtractHeaderValueRetrievesFirstValue
func TestExtractHeaderValueRetrievesFirstValue(t *testing.T) {
r := mocks.NewResponse()
v := []string{"v1", "v2", "v3"}
mocks.SetResponseHeaderValues(r, mocks.TestHeader, v)
if ExtractHeaderValue(mocks.TestHeader, r) != v[0] {
t.Errorf("autorest: ExtractHeader failed to retrieve the expected header -- expected [%s]%v, received [%s]%v",
mocks.TestHeader, v[0], mocks.TestHeader, ExtractHeaderValue(mocks.TestHeader, r))
}
}
示例15: TestWithErrorUnlessOK
func TestWithErrorUnlessOK(t *testing.T) {
r := mocks.NewResponse()
r.Request = mocks.NewRequest()
err := Respond(r,
WithErrorUnlessOK(),
ByClosingIfError())
if err != nil {
t.Errorf("autorest: WithErrorUnlessOK returned an error for OK status code (%v)", err)
}
}