mirror of https://github.com/coder/coder.git
test: Fix generated workspace name length (#7228)
This commit is contained in:
parent
d8eda97dbe
commit
ad0070354f
|
@ -1069,7 +1069,12 @@ func NewAzureInstanceIdentity(t *testing.T, instanceID string) (x509.VerifyOptio
|
|||
func randomUsername(t testing.TB) string {
|
||||
suffix, err := cryptorand.String(3)
|
||||
require.NoError(t, err)
|
||||
return strings.ReplaceAll(namesgenerator.GetRandomName(10), "_", "-") + "-" + suffix
|
||||
suffix = "-" + suffix
|
||||
n := strings.ReplaceAll(namesgenerator.GetRandomName(10), "_", "-") + suffix
|
||||
if len(n) > 32 {
|
||||
n = n[:32-len(suffix)] + suffix
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
// Used to easily create an HTTP transport!
|
||||
|
|
|
@ -106,6 +106,9 @@ func TestWorkspace(t *testing.T) {
|
|||
defer cancel()
|
||||
|
||||
want := ws1.Name + "-test"
|
||||
if len(want) > 32 {
|
||||
want = want[:32-5] + "-test"
|
||||
}
|
||||
err := client.UpdateWorkspace(ctx, ws1.ID, codersdk.UpdateWorkspaceRequest{
|
||||
Name: want,
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue