mirror of
https://github.com/hatchet-dev/hatchet.git
synced 2026-01-04 07:39:43 -06:00
* re-add new testing harness * add healthcheck port and pick random grpc port to listen on * feat: parallel load tests and faster tests * make parallelism = 5 * fix: lint * add linter to pre * fix: add back rampup fixes * reduce matrix on PR, add matrix to pre-release step * make load tests less likely to block * make limit strategy group round robin * uncomment lines
53 lines
1.1 KiB
Go
53 lines
1.1 KiB
Go
//go:build !e2e && !load && !rampup && !integration
|
|
|
|
package random
|
|
|
|
import (
|
|
"fmt"
|
|
"regexp"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestGenerateRandomString(t *testing.T) {
|
|
type args struct {
|
|
n int
|
|
}
|
|
tests := []struct {
|
|
name string
|
|
args args
|
|
want func(string) bool
|
|
wantErr assert.ErrorAssertionFunc
|
|
}{{
|
|
name: "GenerateRandomString",
|
|
args: args{
|
|
n: 32,
|
|
},
|
|
want: func(s string) bool {
|
|
if match, err := regexp.MatchString(`^[0-9a-zA-Z]+$`, s); err != nil || !match {
|
|
return false
|
|
}
|
|
return len(s) == 32
|
|
},
|
|
wantErr: assert.NoError,
|
|
}}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
got, err := Generate(tt.args.n)
|
|
if !tt.wantErr(t, err, fmt.Sprintf("GenerateRandomString(%v)", tt.args.n)) {
|
|
return
|
|
}
|
|
assert.Equalf(t, true, tt.want(got), "GenerateRandomString(%v)", tt.args.n)
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestGenerateWebhookSecret(t *testing.T) {
|
|
s, err := GenerateWebhookSecret()
|
|
if !assert.NoError(t, err) {
|
|
t.FailNow()
|
|
}
|
|
assert.Equalf(t, 32, len(s), "GenerateWebhookSecret length should be 32")
|
|
}
|