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

Function TestAddonGetWithPRFlag

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

TestAddonGetWithPRFlag tests the --pr flag functionality

(t *testing.T)

Source from the content-addressed store, hash-verified

601
602// TestAddonGetWithPRFlag tests the --pr flag functionality
603func 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
636func TestAddonGetWithVersionFlag(t *testing.T) {

Callers

nothing calls this directly

Calls 5

HasGitHubTokenFunction · 0.92
RunHostCommandFunction · 0.92
ChdirMethod · 0.80
CleanupMethod · 0.80
ErrorMethod · 0.80

Tested by

no test coverage detected