github.com/aavshr/aws-sdk-go@v1.41.3/service/iotdataplane/customizations_test.go (about)

     1  package iotdataplane_test
     2  
     3  import (
     4  	"fmt"
     5  	"testing"
     6  
     7  	"github.com/aavshr/aws-sdk-go/aws"
     8  	"github.com/aavshr/aws-sdk-go/awstesting/unit"
     9  	"github.com/aavshr/aws-sdk-go/service/iotdataplane"
    10  )
    11  
    12  func TestRequireEndpointIfRegionProvided(t *testing.T) {
    13  	svc := iotdataplane.New(unit.Session, &aws.Config{
    14  		Region:                 aws.String("mock-region"),
    15  		DisableParamValidation: aws.Bool(true),
    16  	})
    17  	req, _ := svc.GetThingShadowRequest(nil)
    18  	err := req.Build()
    19  
    20  	if e, a := "", svc.Endpoint; e != a {
    21  		t.Errorf("expect %v, got %v", e, a)
    22  	}
    23  	if err == nil {
    24  		t.Errorf("expect error, got none")
    25  	}
    26  	if e, a := aws.ErrMissingEndpoint, err; e != a {
    27  		t.Errorf("expect %v, got %v", e, a)
    28  	}
    29  }
    30  
    31  func TestRequireEndpointIfNoRegionProvided(t *testing.T) {
    32  	svc := iotdataplane.New(unit.Session, &aws.Config{
    33  		DisableParamValidation: aws.Bool(true),
    34  	})
    35  	fmt.Println(svc.ClientInfo.SigningRegion)
    36  
    37  	req, _ := svc.GetThingShadowRequest(nil)
    38  	err := req.Build()
    39  
    40  	if e, a := "", svc.Endpoint; e != a {
    41  		t.Errorf("expect %v, got %v", e, a)
    42  	}
    43  	if err == nil {
    44  		t.Errorf("expect error, got none")
    45  	}
    46  	if e, a := aws.ErrMissingEndpoint, err; e != a {
    47  		t.Errorf("expect %v, got %v", e, a)
    48  	}
    49  }
    50  
    51  func TestRequireEndpointUsed(t *testing.T) {
    52  	svc := iotdataplane.New(unit.Session, &aws.Config{
    53  		Region:                 aws.String("mock-region"),
    54  		DisableParamValidation: aws.Bool(true),
    55  		Endpoint:               aws.String("https://endpoint"),
    56  	})
    57  	req, _ := svc.GetThingShadowRequest(nil)
    58  	err := req.Build()
    59  
    60  	if e, a := "https://endpoint", svc.Endpoint; e != a {
    61  		t.Errorf("expect %v, got %v", e, a)
    62  	}
    63  	if err != nil {
    64  		t.Errorf("expect no error, got %v", err)
    65  	}
    66  }