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

     1  //go:build go1.10 && integration
     2  // +build go1.10,integration
     3  
     4  package dynamodb
     5  
     6  import (
     7  	"testing"
     8  	"time"
     9  
    10  	"github.com/aavshr/aws-sdk-go/aws"
    11  	"github.com/aavshr/aws-sdk-go/awstesting/integration"
    12  )
    13  
    14  func TestEndpointDiscovery(t *testing.T) {
    15  	sess := integration.SessionWithDefaultRegion("us-west-2")
    16  	svc := New(sess, &aws.Config{EnableEndpointDiscovery: aws.Bool(true)})
    17  
    18  	req, _ := svc.ListTablesRequest(nil)
    19  	err := req.Send()
    20  	if err != nil {
    21  		t.Fatalf("expected no error, got %v", err)
    22  	}
    23  
    24  	timeLimit := time.NewTimer(time.Second * 5)
    25  	defer timeLimit.Stop()
    26  	for !svc.endpointCache.Has(req.Operation.Name) {
    27  		select {
    28  		case <-timeLimit.C:
    29  			t.Fatalf("timed out waiting for endpoint")
    30  		default:
    31  		}
    32  	}
    33  
    34  	req, _ = svc.ListTablesRequest(nil)
    35  	err = req.Send()
    36  	if err != nil {
    37  		t.Fatalf("expected no error, got %v", err)
    38  	}
    39  }