mirror of
https://github.com/rclone/rclone.git
synced 2024-12-04 14:26:42 +01:00
50 lines
1.3 KiB
Go
50 lines
1.3 KiB
Go
package cloudsearchdomain_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/aws/aws-sdk-go/aws"
|
|
"github.com/aws/aws-sdk-go/awstesting/unit"
|
|
"github.com/aws/aws-sdk-go/service/cloudsearchdomain"
|
|
)
|
|
|
|
func TestRequireEndpointIfRegionProvided(t *testing.T) {
|
|
svc := cloudsearchdomain.New(unit.Session, &aws.Config{
|
|
Region: aws.String("mock-region"),
|
|
DisableParamValidation: aws.Bool(true),
|
|
})
|
|
req, _ := svc.SearchRequest(nil)
|
|
err := req.Build()
|
|
|
|
assert.Equal(t, "", svc.Endpoint)
|
|
assert.Error(t, err)
|
|
assert.Equal(t, aws.ErrMissingEndpoint, err)
|
|
}
|
|
|
|
func TestRequireEndpointIfNoRegionProvided(t *testing.T) {
|
|
svc := cloudsearchdomain.New(unit.Session, &aws.Config{
|
|
DisableParamValidation: aws.Bool(true),
|
|
})
|
|
req, _ := svc.SearchRequest(nil)
|
|
err := req.Build()
|
|
|
|
assert.Equal(t, "", svc.Endpoint)
|
|
assert.Error(t, err)
|
|
assert.Equal(t, aws.ErrMissingEndpoint, err)
|
|
}
|
|
|
|
func TestRequireEndpointUsed(t *testing.T) {
|
|
svc := cloudsearchdomain.New(unit.Session, &aws.Config{
|
|
Region: aws.String("mock-region"),
|
|
DisableParamValidation: aws.Bool(true),
|
|
Endpoint: aws.String("https://endpoint"),
|
|
})
|
|
req, _ := svc.SearchRequest(nil)
|
|
err := req.Build()
|
|
|
|
assert.Equal(t, "https://endpoint", svc.Endpoint)
|
|
assert.NoError(t, err)
|
|
}
|