MCPcopy Index your code
hub / github.com/coder/coder / TestSubAgentCreationWithNameRetry

Function TestSubAgentCreationWithNameRetry

agent/agentcontainers/api_test.go:4136–4242  ·  view source on GitHub ↗

TestSubAgentCreationWithNameRetry tests the retry logic when unique constraint violations occur

(t *testing.T)

Source from the content-addressed store, hash-verified

4134
4135// TestSubAgentCreationWithNameRetry tests the retry logic when unique constraint violations occur
4136func TestSubAgentCreationWithNameRetry(t *testing.T) {
4137 t.Parallel()
4138
4139 if runtime.GOOS == "windows" {
4140 t.Skip("Dev Container tests are not supported on Windows")
4141 }
4142
4143 tests := []struct {
4144 name string
4145 workspaceFolders []string
4146 expectedNames []string
4147 takenNames []string
4148 }{
4149 {
4150 name: "SingleCollision",
4151 workspaceFolders: []string{
4152 "/home/coder/foo/project",
4153 "/home/coder/bar/project",
4154 },
4155 expectedNames: []string{
4156 "project",
4157 "bar-project",
4158 },
4159 },
4160 {
4161 name: "MultipleCollisions",
4162 workspaceFolders: []string{
4163 "/home/coder/foo/x/project",
4164 "/home/coder/bar/x/project",
4165 "/home/coder/baz/x/project",
4166 },
4167 expectedNames: []string{
4168 "project",
4169 "x-project",
4170 "baz-x-project",
4171 },
4172 },
4173 {
4174 name: "NameAlreadyTaken",
4175 takenNames: []string{"project", "x-project"},
4176 workspaceFolders: []string{
4177 "/home/coder/foo/x/project",
4178 },
4179 expectedNames: []string{
4180 "foo-x-project",
4181 },
4182 },
4183 }
4184
4185 for _, tt := range tests {
4186 t.Run(tt.name, func(t *testing.T) {
4187 t.Parallel()
4188
4189 var (
4190 ctx = testutil.Context(t, testutil.WaitMedium)
4191 logger = testutil.Logger(t)
4192 mClock = quartz.NewMock(t)
4193 fSAC = &fakeSubAgentClient{logger: logger, agents: make(map[uuid.UUID]agentcontainers.SubAgent)}

Callers

nothing calls this directly

Calls 15

StartMethod · 0.95
CloseMethod · 0.95
RefreshContainersMethod · 0.95
ContextFunction · 0.92
LoggerFunction · 0.92
NewAPIFunction · 0.92
WithClockFunction · 0.92
WithContainerCLIFunction · 0.92
WithDevcontainerCLIFunction · 0.92
WithSubAgentClientFunction · 0.92
WithWatcherFunction · 0.92
NewNoopFunction · 0.92

Tested by

no test coverage detected