mirror of
https://github.com/coder/coder.git
synced 2025-07-06 15:41:45 +00:00
chore(testutil): add testutil.GetRandomName that does not return duplicates (#14020)
Fixes #13910 Adds testutil.GetRandomName that replaces namesgenerator.GetRandomName but instead appends a monotonically increasing integer instead of a number between 1 and 10.
This commit is contained in:
@ -4,11 +4,11 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/moby/moby/pkg/namesgenerator"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/coder/coder/v2/coderd/httpapi"
|
||||
"github.com/coder/coder/v2/testutil"
|
||||
)
|
||||
|
||||
func TestUsernameValid(t *testing.T) {
|
||||
@ -168,7 +168,7 @@ func TestGeneratedTemplateVersionNameValid(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
for i := 0; i < 1000; i++ {
|
||||
name := namesgenerator.GetRandomName(1)
|
||||
name := testutil.GetRandomName(t)
|
||||
err := httpapi.TemplateVersionNameValid(name)
|
||||
require.NoError(t, err, "invalid template version name: %s", name)
|
||||
}
|
||||
|
Reference in New Issue
Block a user