(t *testing.T)
| 207 | } |
| 208 | |
| 209 | func 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: "", |
nothing calls this directly
no test coverage detected