(t *testing.T)
| 505 | } |
| 506 | |
| 507 | func TestUpdateCmd_UpdatePortRepo_CircularDependency(t *testing.T) { |
| 508 | // Cleanup. |
| 509 | dirs.RemoveAllForTest() |
| 510 | |
| 511 | // Check error. |
| 512 | var check = func(err error) { |
| 513 | t.Helper() |
| 514 | if err != nil { |
| 515 | t.Fatal(err) |
| 516 | } |
| 517 | } |
| 518 | |
| 519 | // Init celer. |
| 520 | var ( |
| 521 | windowsPlatform = expr.If(os.Getenv("GITHUB_ACTIONS") == "true", "x86_64-windows-msvc-enterprise-14", "x86_64-windows-msvc-community-14") |
| 522 | platform = expr.If(runtime.GOOS == "windows", windowsPlatform, "x86_64-linux-ubuntu-22.04-gcc-11.5.0") |
| 523 | project = "project_test_update" |
| 524 | ) |
| 525 | |
| 526 | celer := configs.NewCeler() |
| 527 | check(celer.Init()) |
| 528 | check(celer.CloneConf(test_conf_repo_url, test_conf_repo_branch, true)) |
| 529 | check(celer.SetBuildType("Release")) |
| 530 | check(celer.SetPlatform(platform)) |
| 531 | check(celer.SetProject(project)) |
| 532 | |
| 533 | // Test circular dependency detection. |
| 534 | t.Run("circular dependency prevention", func(t *testing.T) { |
| 535 | visited := make(map[string]bool) |
| 536 | |
| 537 | // Simulate visiting the same port twice. |
| 538 | visited["test-port@1.0.0"] = true |
| 539 | |
| 540 | updateCmd := updateCmd{ |
| 541 | celer: celer, |
| 542 | recursive: true, |
| 543 | force: false, |
| 544 | } |
| 545 | |
| 546 | // This should return nil immediately due to visited check. |
| 547 | if err := updateCmd.updatePortRepo("test-port@1.0.0", visited); err != nil { |
| 548 | // If error occurs, it should not be about circular dependency, |
| 549 | // (the visited check should prevent that). |
| 550 | t.Logf("Got error (acceptable if not about infinite recursion): %v", err) |
| 551 | } |
| 552 | }) |
| 553 | } |
| 554 | |
| 555 | func TestUpdateCmd_UpdatePortRepo_WithGitRepo(t *testing.T) { |
| 556 | // Cleanup. |
nothing calls this directly
no test coverage detected