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

Function TestExpandedAgentName

agent/agentcontainers/api_internal_test.go:209–358  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

207}
208
209func TestExpandedAgentName(t *testing.T) {
210 t.Parallel()
211
212 tests := []struct {
213 name string
214 workspaceFolder string
215 friendlyName string
216 depth int
217 expected string
218 fallback bool
219 }{
220 {
221 name: "simple path depth 1",
222 workspaceFolder: "/home/coder/project",
223 friendlyName: "friendly-fallback",
224 depth: 0,
225 expected: "project",
226 },
227 {
228 name: "simple path depth 2",
229 workspaceFolder: "/home/coder/project",
230 friendlyName: "friendly-fallback",
231 depth: 1,
232 expected: "coder-project",
233 },
234 {
235 name: "simple path depth 3",
236 workspaceFolder: "/home/coder/project",
237 friendlyName: "friendly-fallback",
238 depth: 2,
239 expected: "home-coder-project",
240 },
241 {
242 name: "simple path depth exceeds available",
243 workspaceFolder: "/home/coder/project",
244 friendlyName: "friendly-fallback",
245 depth: 9,
246 expected: "home-coder-project",
247 },
248 // Cases with special characters that need sanitization
249 {
250 name: "path with spaces and special chars",
251 workspaceFolder: "/home/coder/My Project_v2",
252 friendlyName: "friendly-fallback",
253 depth: 1,
254 expected: "coder-my-project-v2",
255 },
256 {
257 name: "path with dots and underscores",
258 workspaceFolder: "/home/user.name/project_folder.git",
259 friendlyName: "friendly-fallback",
260 depth: 1,
261 expected: "user-name-project-folder-git",
262 },
263 // Edge cases
264 {
265 name: "empty path",
266 workspaceFolder: "",

Callers

nothing calls this directly

Calls 4

expandedAgentNameFunction · 0.85
MatchMethod · 0.80
RunMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected