TestAddonGetWithPRFlag tests the --pr flag functionality
(t *testing.T)
| 601 | |
| 602 | // TestAddonGetWithPRFlag tests the --pr flag functionality |
| 603 | func TestAddonGetWithPRFlag(t *testing.T) { |
| 604 | if !github.HasGitHubToken() { |
| 605 | t.Skip("Skipping because DDEV_GITHUB_TOKEN is not set") |
| 606 | } |
| 607 | origDir, _ := os.Getwd() |
| 608 | site := TestSites[0] |
| 609 | err := os.Chdir(site.Dir) |
| 610 | require.NoError(t, err) |
| 611 | |
| 612 | t.Cleanup(func() { |
| 613 | assert := asrt.New(t) |
| 614 | _, _ = exec.RunHostCommand(DdevBin, "add-on", "remove", "ddev-redis") |
| 615 | err = os.Chdir(origDir) |
| 616 | assert.NoError(err) |
| 617 | }) |
| 618 | |
| 619 | // Test that --pr flag with invalid value fails |
| 620 | out, err := exec.RunHostCommand(DdevBin, "add-on", "get", "ddev/ddev-redis", "--pr", "0") |
| 621 | require.Error(t, err, "Should fail with --pr=0, out=%s", out) |
| 622 | require.Contains(t, out, "--pr flag requires a positive integer value") |
| 623 | |
| 624 | // Test that --pr flag with negative value fails |
| 625 | out, err = exec.RunHostCommand(DdevBin, "add-on", "get", "ddev/ddev-redis", "--pr", "-1") |
| 626 | require.Error(t, err, "Should fail with --pr=-1, out=%s", out) |
| 627 | require.Contains(t, out, "--pr flag requires a positive integer value") |
| 628 | |
| 629 | // Test that --pr flag with valid value works (PR #54 exists for ddev-redis) |
| 630 | out, err = exec.RunHostCommand(DdevBin, "add-on", "get", "ddev/ddev-redis", "--pr", "54") |
| 631 | require.NoError(t, err, "Should succeed with --pr=54, out=%s", out) |
| 632 | require.Contains(t, out, "Installing ddev/ddev-redis:pr-54") |
| 633 | } |
| 634 | |
| 635 | // TestAddonGetWithVersionFlag tests the --version flag functionality |
| 636 | func TestAddonGetWithVersionFlag(t *testing.T) { |
nothing calls this directly
no test coverage detected