github.com/aavshr/aws-sdk-go@v1.41.3/aws/request/request_1_6_test.go (about)

     1  //go:build go1.6
     2  // +build go1.6
     3  
     4  package request_test
     5  
     6  import (
     7  	"errors"
     8  	"testing"
     9  
    10  	"github.com/aavshr/aws-sdk-go/aws"
    11  	"github.com/aavshr/aws-sdk-go/aws/awserr"
    12  	"github.com/aavshr/aws-sdk-go/aws/client"
    13  	"github.com/aavshr/aws-sdk-go/aws/client/metadata"
    14  	"github.com/aavshr/aws-sdk-go/aws/defaults"
    15  	"github.com/aavshr/aws-sdk-go/aws/request"
    16  )
    17  
    18  // go version 1.4 and 1.5 do not return an error. Version 1.5 will url encode
    19  // the uri while 1.4 will not
    20  func TestRequestInvalidEndpoint(t *testing.T) {
    21  	endpoint := "http://localhost:90 "
    22  
    23  	r := request.New(
    24  		aws.Config{},
    25  		metadata.ClientInfo{Endpoint: endpoint},
    26  		defaults.Handlers(),
    27  		client.DefaultRetryer{},
    28  		&request.Operation{},
    29  		nil,
    30  		nil,
    31  	)
    32  
    33  	if r.Error == nil {
    34  		t.Errorf("expect error")
    35  	}
    36  }
    37  
    38  type timeoutErr struct {
    39  	error
    40  }
    41  
    42  var errTimeout = awserr.New("foo", "bar", &timeoutErr{
    43  	errors.New("net/http: request canceled"),
    44  })
    45  
    46  func (e *timeoutErr) Timeout() bool {
    47  	return true
    48  }
    49  
    50  func (e *timeoutErr) Temporary() bool {
    51  	return true
    52  }