github.com/webdestroya/awsmocker@v0.2.6/internal/testutil/util.go (about)

     1  package testutil
     2  
     3  import (
     4  	"bytes"
     5  	"context"
     6  	"io"
     7  
     8  	"github.com/aws/aws-sdk-go-v2/aws"
     9  	"github.com/aws/aws-sdk-go-v2/config"
    10  	"github.com/aws/aws-sdk-go-v2/credentials"
    11  )
    12  
    13  func GetAwsConfig() aws.Config {
    14  	cfg, err := config.LoadDefaultConfig(context.TODO(),
    15  		// add creds just in case something happens
    16  		config.WithCredentialsProvider(credentials.NewStaticCredentialsProvider("XXfakekey", "XXfakesecret", "xxtoken")),
    17  		config.WithDefaultRegion("us-east-1"),
    18  		config.WithRetryer(func() aws.Retryer {
    19  			return aws.NopRetryer{}
    20  		}),
    21  	)
    22  	if err != nil {
    23  		panic(err)
    24  	}
    25  	return cfg
    26  }
    27  
    28  func ReaderToString(rdr io.ReadCloser) string {
    29  	defer rdr.Close()
    30  
    31  	var buf bytes.Buffer
    32  	_, _ = io.Copy(&buf, rdr)
    33  
    34  	return buf.String()
    35  }