test: Fix generated workspace name length (#7228)

This commit is contained in:
Mathias Fredriksson 2023-04-20 21:40:36 +03:00 committed by GitHub
parent d8eda97dbe
commit ad0070354f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -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!

View File

@ -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,
})