aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/aws/aws-sdk-go-v2/service/s3/internal/s3testing/s3testing.go
blob: c12e468718af101ae003e1e20343c8b5a287c809 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package s3testing

import (
	"fmt"
	"math/rand"

	"github.com/aws/aws-sdk-go-v2/internal/sdkio"
)

var randBytes = func() []byte {
	b := make([]byte, 10*sdkio.MebiByte)

	if _, err := rand.Read(b); err != nil {
		panic(fmt.Sprintf("failed to read random bytes, %v", err))
	}
	return b
}()

// GetTestBytes returns a pseudo-random []byte of length size
func GetTestBytes(size int) []byte {
	if len(randBytes) >= size {
		return randBytes[:size]
	}

	b := append(randBytes, GetTestBytes(size-len(randBytes))...)
	return b
}