Skip to content

test: Fix generated workspace name length #7228

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
test: Fix generated workspace name length
  • Loading branch information
mafredri committed Apr 20, 2023
commit b2b9d7f2f2b213fe4434e06fa6c274429ee53f04
7 changes: 6 additions & 1 deletion coderd/coderdtest/coderdtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down
3 changes: 3 additions & 0 deletions coderd/workspaces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
Expand Down