mirror of
https://github.com/coder/coder.git
synced 2026-06-03 21:18:24 +00:00
dc7be5f43a
- Update Go version from 1.24.11 to 1.25.6
- Remove dependency on `moby` for `namesgenerator`
- Disable any use of trivy in zizmor GH action linting
(https://github.com/coder/coder/pull/23228/commits/17532ef2a8e40784499c36d3e7b871a2109d9bf2)
---------
(cherry picked from commit 3ee4f6d0ec)
(cherry picked from commit
https://github.com/coder/coder/commit/091d31224d2fe00d83695adcc53a225842dbb8d3)
(cherry picked from commit
https://github.com/coder/coder/commit/b44a421412a12ef7222322c68109426fb1f65286)
---------
Co-authored-by: Danny Kopping <danny@coder.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: Zach <3724288+zedkipp@users.noreply.github.com>
53 lines
1.6 KiB
Go
53 lines
1.6 KiB
Go
package coderdtest_test
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
"unicode"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
"go.uber.org/goleak"
|
|
|
|
"github.com/coder/coder/v2/coderd/coderdtest"
|
|
"github.com/coder/coder/v2/testutil"
|
|
)
|
|
|
|
func TestMain(m *testing.M) {
|
|
goleak.VerifyTestMain(m, testutil.GoleakOptions...)
|
|
}
|
|
|
|
func TestNew(t *testing.T) {
|
|
t.Parallel()
|
|
client := coderdtest.New(t, &coderdtest.Options{
|
|
IncludeProvisionerDaemon: true,
|
|
})
|
|
user := coderdtest.CreateFirstUser(t, client)
|
|
version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, nil)
|
|
_ = coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID)
|
|
template := coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
|
|
workspace := coderdtest.CreateWorkspace(t, client, template.ID)
|
|
coderdtest.AwaitWorkspaceBuildJobCompleted(t, client, workspace.LatestBuild.ID)
|
|
coderdtest.AwaitWorkspaceAgents(t, client, workspace.ID)
|
|
_, _ = coderdtest.NewGoogleInstanceIdentity(t, "example", false)
|
|
_, _ = coderdtest.NewAWSInstanceIdentity(t, "an-instance")
|
|
}
|
|
|
|
func TestRandomName(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
for range 10 {
|
|
name := coderdtest.RandomName(t)
|
|
|
|
require.NotEmpty(t, name, "name should not be empty")
|
|
require.NotContains(t, name, "_", "name should not contain underscores")
|
|
|
|
// Should be title cased (e.g., "Happy Einstein").
|
|
words := strings.Split(name, " ")
|
|
require.Len(t, words, 2, "name should have exactly two words")
|
|
for _, word := range words {
|
|
firstRune := []rune(word)[0]
|
|
require.True(t, unicode.IsUpper(firstRune), "word %q should start with uppercase letter", word)
|
|
}
|
|
}
|
|
}
|