(t *testing.T, nameVersion string, option configs.RemoveOptions)
| 537 | } |
| 538 | |
| 539 | func installForTestRemove(t *testing.T, nameVersion string, option configs.RemoveOptions) configs.Port { |
| 540 | // Check error. |
| 541 | var check = func(err error) { |
| 542 | t.Helper() |
| 543 | if err != nil { |
| 544 | t.Fatal(err) |
| 545 | } |
| 546 | } |
| 547 | |
| 548 | // Cleanup workspace. |
| 549 | dirs.RemoveAllForTest() |
| 550 | |
| 551 | var ( |
| 552 | windowsPlatform = expr.If(os.Getenv("GITHUB_ACTIONS") == "true", "x86_64-windows-msvc-enterprise-14", "x86_64-windows-msvc-community-14") |
| 553 | platform = expr.If(runtime.GOOS == "windows", windowsPlatform, "x86_64-linux-ubuntu-22.04-gcc-11.5.0") |
| 554 | project = "project_test_remove" |
| 555 | ) |
| 556 | |
| 557 | // Init celer. |
| 558 | celer := configs.NewCeler() |
| 559 | check(celer.Init()) |
| 560 | check(celer.CloneConf(test_conf_repo_url, test_conf_repo_branch, true)) |
| 561 | check(celer.SetBuildType("Release")) |
| 562 | check(celer.SetPlatform(platform)) |
| 563 | check(celer.SetProject(project)) |
| 564 | |
| 565 | var ( |
| 566 | packageFolder = filepath.Join(platform, project, celer.BuildType(), nameVersion) |
| 567 | port configs.Port |
| 568 | options configs.InstallOptions |
| 569 | ) |
| 570 | |
| 571 | check(port.Init(celer, nameVersion)) |
| 572 | check(port.InstallFromSource(options)) |
| 573 | |
| 574 | // Check if package dir exists. |
| 575 | packageDir := filepath.Join(dirs.PackagesDir, packageFolder) |
| 576 | if !fileio.PathExists(packageDir) { |
| 577 | t.Fatalf("package dir cannot found : %s", packageDir) |
| 578 | } |
| 579 | |
| 580 | // Check if installed. |
| 581 | installed, err := port.Installed() |
| 582 | check(err) |
| 583 | if !installed { |
| 584 | t.Fatal("package is not installed") |
| 585 | } |
| 586 | |
| 587 | check(port.Remove(option)) |
| 588 | return port |
| 589 | } |
no test coverage detected