MCPcopy Create free account
hub / github.com/ddev/ddev / TestCmdAddonProjectFlag

Function TestCmdAddonProjectFlag

cmd/ddev/cmd/addon-get_test.go:563–600  ·  view source on GitHub ↗

TestAddonGetWithPRFlag tests the --project flag functionality

(t *testing.T)

Source from the content-addressed store, hash-verified

561
562// TestAddonGetWithPRFlag tests the --project flag functionality
563func 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
603func TestAddonGetWithPRFlag(t *testing.T) {

Callers

nothing calls this directly

Calls 6

HasGitHubTokenFunction · 0.92
RunHostCommandFunction · 0.92
GetGlobalDdevDirFunction · 0.92
getManifestFromLogsFunction · 0.85
getManifestMapFromLogsFunction · 0.85
CleanupMethod · 0.80

Tested by

no test coverage detected