TestAddonGetWithPRFlag tests the --project flag functionality
(t *testing.T)
| 561 | |
| 562 | // TestAddonGetWithPRFlag tests the --project flag functionality |
| 563 | func TestCmdAddonProjectFlag(t *testing.T) { |
| 564 | if !github.HasGitHubToken() { |
| 565 | t.Skip("Skipping because DDEV_GITHUB_TOKEN is not set") |
| 566 | } |
| 567 | t.Setenv("DDEV_DEBUG", "") |
| 568 | assert := asrt.New(t) |
| 569 | |
| 570 | site := TestSites[0] |
| 571 | // Explicitly don't chdir to the project |
| 572 | |
| 573 | t.Cleanup(func() { |
| 574 | _, err := exec.RunHostCommand(DdevBin, "add-on", "remove", "redis", "--project", site.Name) |
| 575 | assert.NoError(err) |
| 576 | _ = os.RemoveAll(filepath.Join(globalconfig.GetGlobalDdevDir(), "commands/web/global-touched")) |
| 577 | }) |
| 578 | |
| 579 | // Install the add-on using the `--project` flag |
| 580 | out, err := exec.RunHostCommand(DdevBin, "add-on", "get", "ddev/ddev-redis", "--project", site.Name, "--json-output") |
| 581 | require.NoError(t, err, "failed ddev add-on get ddev/ddev-redis --project %s --json-output: %v (output='%s')", site.Name, err, out) |
| 582 | |
| 583 | redisManifest := getManifestFromLogs(t, out) |
| 584 | require.NoError(t, err) |
| 585 | |
| 586 | installedOutput, err := exec.RunHostCommand(DdevBin, "add-on", "list", "--installed", "--project", site.Name, "--json-output") |
| 587 | require.NoError(t, err, "failed ddev add-on list --installed --project %s --json-output: %v (output='%s')", site.Name, err, installedOutput) |
| 588 | installedManifests := getManifestMapFromLogs(t, installedOutput) |
| 589 | |
| 590 | require.NotEmptyf(t, redisManifest["Version"], "redis manifest is empty: %v", redisManifest) |
| 591 | assert.Equal(redisManifest["Version"], installedManifests["redis"]["Version"]) |
| 592 | |
| 593 | // Remove the add-on using the `--project` flag |
| 594 | out, err = exec.RunHostCommand(DdevBin, "add-on", "remove", "ddev/ddev-redis", "--project", site.Name) |
| 595 | require.NoError(t, err, "unable to ddev add-on remove ddev/ddev-redis --project %s: %v, output='%s'", site.Name, err, out) |
| 596 | |
| 597 | // Now make sure we put it back so it can be removed in cleanup |
| 598 | out, err = exec.RunHostCommand(DdevBin, "add-on", "get", "ddev/ddev-redis", "--project", site.Name) |
| 599 | assert.NoError(err, "unable to ddev add-on get ddev/ddev-redis --project %s: %v, output='%s'", site.Name, err, out) |
| 600 | } |
| 601 | |
| 602 | // TestAddonGetWithPRFlag tests the --pr flag functionality |
| 603 | func TestAddonGetWithPRFlag(t *testing.T) { |
nothing calls this directly
no test coverage detected