=================================================================== Parser unit tests — parseLsOutput ===================================================================
(t *testing.T)
| 320 | // =================================================================== |
| 321 | |
| 322 | func TestParseLsOutput_Windows(t *testing.T) { |
| 323 | t.Parallel() |
| 324 | resp := parseLsOutput(windowsDirOutput, "Windows", "D:\\Programing\\AI\\CLIProxyAPI") |
| 325 | |
| 326 | if !resp.Exists { |
| 327 | t.Error("expected Exists=true") |
| 328 | } |
| 329 | |
| 330 | if len(resp.Files) == 0 { |
| 331 | t.Fatal("expected files, got 0") |
| 332 | } |
| 333 | |
| 334 | // Verify .dockerignore (file). |
| 335 | found := false |
| 336 | for _, f := range resp.Files { |
| 337 | if f.Name == ".dockerignore" && !f.IsDir && f.Size == 487 { |
| 338 | found = true |
| 339 | break |
| 340 | } |
| 341 | } |
| 342 | if !found { |
| 343 | t.Error("expected .dockerignore file with size 487") |
| 344 | } |
| 345 | |
| 346 | // Verify .git (directory). |
| 347 | found = false |
| 348 | for _, f := range resp.Files { |
| 349 | if f.Name == ".git" && f.IsDir { |
| 350 | found = true |
| 351 | break |
| 352 | } |
| 353 | } |
| 354 | if !found { |
| 355 | t.Error("expected .git directory") |
| 356 | } |
| 357 | |
| 358 | // Verify cliproxy.exe (large file). |
| 359 | found = false |
| 360 | for _, f := range resp.Files { |
| 361 | if f.Name == "cliproxy.exe" && f.Size == 66036736 { |
| 362 | found = true |
| 363 | break |
| 364 | } |
| 365 | } |
| 366 | if !found { |
| 367 | t.Errorf("expected cliproxy.exe with size 66036736, files: %+v", resp.Files) |
| 368 | } |
| 369 | |
| 370 | // Ensure "." and ".." are excluded. |
| 371 | for _, f := range resp.Files { |
| 372 | if f.Name == "." || f.Name == ".." { |
| 373 | t.Errorf("should not include %q", f.Name) |
| 374 | } |
| 375 | } |
| 376 | } |
| 377 | |
| 378 | func TestParseLsOutput_Linux(t *testing.T) { |
| 379 | t.Parallel() |
nothing calls this directly
no test coverage detected