Skip to content

Commit

Permalink
testing: use strings.Repeat
Browse files Browse the repository at this point in the history
  • Loading branch information
peterjan committed Nov 27, 2023
1 parent 0747866 commit 7aa8b01
Showing 1 changed file with 13 additions and 21 deletions.
34 changes: 13 additions & 21 deletions internal/testing/s3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -603,15 +603,6 @@ func TestS3SettingsValidate(t *testing.T) {
t.SkipNow()
}

charset := "doesntreallymatter"
stringOfLength := func(n int) string {
b := make([]byte, n)
for i := range b {
b[i] = charset[frand.Intn(len(charset))]
}
return string(b)
}

cluster := newTestCluster(t, clusterOptsDefault)
defer cluster.Shutdown()

Expand All @@ -621,38 +612,39 @@ func TestS3SettingsValidate(t *testing.T) {
shouldFail bool
}{
{
id: stringOfLength(api.S3MinAccessKeyLen),
key: stringOfLength(api.S3SecretKeyLen),

id: strings.Repeat("a", api.S3MinAccessKeyLen),
key: strings.Repeat("a", api.S3SecretKeyLen),
shouldFail: false,
},
{
id: stringOfLength(api.S3MaxAccessKeyLen),
key: stringOfLength(api.S3SecretKeyLen),
id: strings.Repeat("a", api.S3MaxAccessKeyLen),
key: strings.Repeat("a", api.S3SecretKeyLen),
shouldFail: false,
},
{
id: stringOfLength(api.S3MinAccessKeyLen - 1),
key: stringOfLength(api.S3SecretKeyLen),
id: strings.Repeat("a", api.S3MinAccessKeyLen-1),
key: strings.Repeat("a", api.S3SecretKeyLen),
shouldFail: true,
},
{
id: stringOfLength(api.S3MaxAccessKeyLen + 1),
key: stringOfLength(api.S3SecretKeyLen),
id: strings.Repeat("a", api.S3MaxAccessKeyLen+1),
key: strings.Repeat("a", api.S3SecretKeyLen),
shouldFail: true,
},
{
id: "",
key: stringOfLength(api.S3SecretKeyLen),
key: strings.Repeat("a", api.S3SecretKeyLen),
shouldFail: true,
},
{
id: stringOfLength(api.S3MinAccessKeyLen),
id: strings.Repeat("a", api.S3MinAccessKeyLen),
key: "",
shouldFail: true,
},
{
id: stringOfLength(api.S3MinAccessKeyLen),
key: stringOfLength(api.S3SecretKeyLen + 1),
id: strings.Repeat("a", api.S3MinAccessKeyLen),
key: strings.Repeat("a", api.S3SecretKeyLen+1),
shouldFail: true,
},
}
Expand Down

0 comments on commit 7aa8b01

Please sign in to comment.