chore(test): enable parallel test execution

Seems to cut overall total test time down to one third the time.
This commit is contained in:
2021-12-16 20:16:03 +00:00
parent 164ccc497a
commit b59d421322
3 changed files with 34 additions and 0 deletions

View File

@@ -7,6 +7,8 @@ import (
) )
func TestBytes(t *testing.T) { func TestBytes(t *testing.T) {
t.Parallel()
for _, tt := range testCases { for _, tt := range testCases {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
got, _ := Bytes(tt.n) got, _ := Bytes(tt.n)

View File

@@ -91,6 +91,8 @@ var testIntCases = []struct {
} }
func TestInt(t *testing.T) { func TestInt(t *testing.T) {
t.Parallel()
for _, tt := range testIntCases { for _, tt := range testIntCases {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
got, err := Int(tt.max) got, err := Int(tt.max)
@@ -122,6 +124,8 @@ func BenchmarkInt(b *testing.B) {
} }
func TestInt64(t *testing.T) { func TestInt64(t *testing.T) {
t.Parallel()
for _, tt := range testIntCases { for _, tt := range testIntCases {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
got, err := Int64(int64(tt.max)) got, err := Int64(int64(tt.max))

View File

@@ -12,6 +12,8 @@ import (
) )
func TestHex(t *testing.T) { func TestHex(t *testing.T) {
t.Parallel()
allowed := "0123456789abcdef" allowed := "0123456789abcdef"
for _, tt := range testCases { for _, tt := range testCases {
@@ -35,6 +37,8 @@ func BenchmarkHex(b *testing.B) {
} }
func TestBase64(t *testing.T) { func TestBase64(t *testing.T) {
t.Parallel()
allowed := "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" + allowed := "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" +
"0123456789+/=" "0123456789+/="
@@ -62,6 +66,8 @@ func BenchmarkBase64(b *testing.B) {
} }
func TestBase64URL(t *testing.T) { func TestBase64URL(t *testing.T) {
t.Parallel()
allowed := "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" + allowed := "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" +
"0123456789-_" "0123456789-_"
@@ -89,6 +95,8 @@ func BenchmarkBase64URL(b *testing.B) {
} }
func TestAlphanumeric(t *testing.T) { func TestAlphanumeric(t *testing.T) {
t.Parallel()
allowed := "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" allowed := "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
for _, tt := range testCases { for _, tt := range testCases {
@@ -112,6 +120,8 @@ func BenchmarkAlphanumeric(b *testing.B) {
} }
func TestAlphabetic(t *testing.T) { func TestAlphabetic(t *testing.T) {
t.Parallel()
allowed := "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" allowed := "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
for _, tt := range testCases { for _, tt := range testCases {
@@ -135,6 +145,8 @@ func BenchmarkAlphabetic(b *testing.B) {
} }
func TestNumeric(t *testing.T) { func TestNumeric(t *testing.T) {
t.Parallel()
allowed := "0123456789" allowed := "0123456789"
for _, tt := range testCases { for _, tt := range testCases {
@@ -158,6 +170,8 @@ func BenchmarkNumeric(b *testing.B) {
} }
func TestUpper(t *testing.T) { func TestUpper(t *testing.T) {
t.Parallel()
allowed := "ABCDEFGHIJKLMNOPQRSTUVWXYZ" allowed := "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
for _, tt := range testCases { for _, tt := range testCases {
@@ -181,6 +195,8 @@ func BenchmarkUpper(b *testing.B) {
} }
func TestUpperNumeric(t *testing.T) { func TestUpperNumeric(t *testing.T) {
t.Parallel()
allowed := "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" allowed := "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
for _, tt := range testCases { for _, tt := range testCases {
@@ -204,6 +220,8 @@ func BenchmarkUpperNumeric(b *testing.B) {
} }
func TestLower(t *testing.T) { func TestLower(t *testing.T) {
t.Parallel()
allowed := "abcdefghijklmnopqrstuvwxyz" allowed := "abcdefghijklmnopqrstuvwxyz"
for _, tt := range testCases { for _, tt := range testCases {
@@ -227,6 +245,8 @@ func BenchmarkLower(b *testing.B) {
} }
func TestLowerNumeric(t *testing.T) { func TestLowerNumeric(t *testing.T) {
t.Parallel()
allowed := "abcdefghijklmnopqrstuvwxyz0123456789" allowed := "abcdefghijklmnopqrstuvwxyz0123456789"
for _, tt := range testCases { for _, tt := range testCases {
@@ -348,6 +368,8 @@ var stringTestCases = []struct {
} }
func TestString(t *testing.T) { func TestString(t *testing.T) {
t.Parallel()
for _, tt := range stringTestCases { for _, tt := range stringTestCases {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
got, err := String(tt.n, tt.alphabet) got, err := String(tt.n, tt.alphabet)
@@ -475,6 +497,8 @@ var unicodeStringTestCases = []struct {
} }
func TestUnicodeString(t *testing.T) { func TestUnicodeString(t *testing.T) {
t.Parallel()
for _, tt := range unicodeStringTestCases { for _, tt := range unicodeStringTestCases {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
got, _ := UnicodeString(tt.n, []rune(tt.alphabet)) got, _ := UnicodeString(tt.n, []rune(tt.alphabet))
@@ -545,6 +569,8 @@ var dnsLabelTestCases = []struct {
} }
func TestDNSLabel(t *testing.T) { func TestDNSLabel(t *testing.T) {
t.Parallel()
for _, tt := range dnsLabelTestCases { for _, tt := range dnsLabelTestCases {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
// generate lots of labels to increase the chances of catching any // generate lots of labels to increase the chances of catching any
@@ -580,6 +606,8 @@ func BenchmarkDNSLabel(b *testing.B) {
} }
func TestUUID(t *testing.T) { func TestUUID(t *testing.T) {
t.Parallel()
m := regexp.MustCompile( m := regexp.MustCompile(
`^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$`, `^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$`,
) )