Documentation
¶
Overview ¶
Package testrand implements generating random base types for testing.
Index ¶
- func BucketName() string
- func Bytes(size memory.Size) []byte
- func BytesInt(size int) []byte
- func Float64n(n int64) float64
- func Int63n(n int64) int64
- func Intn(n int) int
- func Key() storj.Key
- func NodeID() storj.NodeID
- func Nonce() storj.Nonce
- func Path() string
- func PieceID() storj.PieceID
- func RandAlphaNumeric(length int) []byte
- func RandNumeric(length int) []byte
- func Read(data []byte)
- func Reader() io.Reader
- func SegmentID(size int) storj.SegmentID
- func SerialNumber() storj.SerialNumber
- func StreamID(size int) storj.StreamID
- func URLPath() string
- func URLPathNonFolder() string
- func UUID() uuid.UUID
- type TestMetadata
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BucketName ¶
func BucketName() string
BucketName creates a random bucket name mostly confirming to the restrictions of S3: https://docs.aws.amazon.com/AmazonS3/latest/dev/BucketRestrictions.html
NOTE: This may not generate values that cover all valid values (for Storj or S3). This is a best effort to cover most cases we believe our design requires and will need to be revisited when a more explicit design spec is created.
func Float64n ¶
Float64n returns floating point pseudo-random number in [-n,0] || [0,n] based on the sign of the input.
func Int63n ¶
Int63n returns, as an int64, a non-negative pseudo-random number in [0,n) from the default Source. It panics if n <= 0.
func Intn ¶
Intn returns, as an int, a non-negative pseudo-random number in [0,n) from the default Source. It panics if n <= 0.
func RandAlphaNumeric ¶
RandAlphaNumeric creates a random byte slice of given length composed of ASCII numbers and letters.
func RandNumeric ¶
RandNumeric creates a random byte slice of given length composed of ASCII numbers.
func SerialNumber ¶
func SerialNumber() storj.SerialNumber
SerialNumber creates a random serial number.
func URLPathNonFolder ¶
func URLPathNonFolder() string
URLPathNonFolder creates a clean random url path that is not a folder.
Types ¶
type TestMetadata ¶
TestMetadata represents randomly generated metadata. Combined with its Metadata constructor and JSON method, it allows for constructions in tests such as `m := testrand.Metadata().JSON()`.
func Metadata ¶
func Metadata() TestMetadata
Metadata creates random metadata mostly conforming to the restrictions of S3: https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html#object-metadata
NOTE: This may not generate values that cover all valid values (for Storj or S3). This is a best effort to cover most cases we believe our design requires and will need to be revisited when a more explicit design spec is created.