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