From a71e5cc8b0bf05f96c65b5320973fe848f48f294 Mon Sep 17 00:00:00 2001 From: Ethan <39577870+ethanndickson@users.noreply.github.com> Date: Fri, 22 Aug 2025 12:20:03 +1000 Subject: [PATCH] test: add increasing integer to GetRandomNameHyphenated (#19481) Fixes flakes like the following: ``` workspaces_test.go:4938: Error Trace: /home/runner/work/coder/coder/coderd/coderdtest/coderdtest.go:1279 /home/runner/work/coder/coder/coderd/workspaces_test.go:4938 /home/runner/work/coder/coder/coderd/workspaces_test.go:5044 Error: Received unexpected error: POST http://127.0.0.1:42597/api/v2/users/me/workspaces: unexpected status code 409: Workspace "romantic-mcclintock" already exists. name: This value is already in use and should be unique. Test: TestWorkspaceCreateWithImplicitPreset/SinglePresetWithParameters ``` https://github.com/coder/coder/actions/runs/17142665868/job/48633017007?pr=19464 Which are caused by insufficient randomness when creating multiple workspaces with random names. Two words is not enough to avoid flakes. We have a `testutil.GetRandomName` function that appends a monotonically increasing integer, but this alternative function that uses hyphens doesn't add that integer. This PR fixes that by just `testutil.GetRandomName` --- testutil/names.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testutil/names.go b/testutil/names.go index e53e854fae..bb804ba2cf 100644 --- a/testutil/names.go +++ b/testutil/names.go @@ -30,7 +30,7 @@ func GetRandomName(t testing.TB) string { // an underscore. func GetRandomNameHyphenated(t testing.TB) string { t.Helper() - name := namesgenerator.GetRandomName(0) + name := GetRandomName(t) return strings.ReplaceAll(name, "_", "-") }