(t *testing.T)
| 449 | } |
| 450 | |
| 451 | func TestUpdateCmd_UpdatePortRepo_NonGitRepo(t *testing.T) { |
| 452 | // Cleanup. |
| 453 | dirs.RemoveAllForTest() |
| 454 | |
| 455 | // Check error. |
| 456 | var check = func(err error) { |
| 457 | t.Helper() |
| 458 | if err != nil { |
| 459 | t.Fatal(err) |
| 460 | } |
| 461 | } |
| 462 | |
| 463 | // Init celer. |
| 464 | var ( |
| 465 | windowsPlatform = expr.If(os.Getenv("GITHUB_ACTIONS") == "true", "x86_64-windows-msvc-enterprise-14", "x86_64-windows-msvc-community-14") |
| 466 | platform = expr.If(runtime.GOOS == "windows", windowsPlatform, "x86_64-linux-ubuntu-22.04-gcc-11.5.0") |
| 467 | project = "project_test_update" |
| 468 | ) |
| 469 | |
| 470 | celer := configs.NewCeler() |
| 471 | check(celer.Init()) |
| 472 | check(celer.CloneConf(test_conf_repo_url, test_conf_repo_branch, true)) |
| 473 | check(celer.SetBuildType("Release")) |
| 474 | check(celer.SetPlatform(platform)) |
| 475 | check(celer.SetProject(project)) |
| 476 | |
| 477 | // Test with a non-git port (if available) |
| 478 | t.Run("update port without git repo", func(t *testing.T) { |
| 479 | // Find a port that's not a git repo |
| 480 | nameVersion := "sqlite3@3.49.0" |
| 481 | |
| 482 | var port configs.Port |
| 483 | check(port.Init(celer, nameVersion)) |
| 484 | |
| 485 | // Create src directory to test the git check |
| 486 | srcDir := filepath.Join(dirs.WorkspaceDir, "buildtrees", nameVersion, "src") |
| 487 | check(os.MkdirAll(srcDir, os.ModePerm)) |
| 488 | |
| 489 | updateCmd := updateCmd{ |
| 490 | celer: celer, |
| 491 | recursive: false, |
| 492 | force: false, |
| 493 | } |
| 494 | |
| 495 | visited := make(map[string]bool) |
| 496 | err := updateCmd.updatePortRepo(nameVersion, visited) |
| 497 | if err == nil { |
| 498 | t.Fatal("updatePortRepo should return error for non-git repo") |
| 499 | } |
| 500 | |
| 501 | if !strings.Contains(err.Error(), "not a git repository") { |
| 502 | t.Errorf("Expected 'not a git repository' error, got: %v", err) |
| 503 | } |
| 504 | }) |
| 505 | } |
| 506 | |
| 507 | func TestUpdateCmd_UpdatePortRepo_CircularDependency(t *testing.T) { |
| 508 | // Cleanup. |
nothing calls this directly
no test coverage detected