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

Function TestGetAddonTarballURL

pkg/ddevapp/addons_test.go:780–905  ·  view source on GitHub ↗

TestGetAddonTarballURL tests the GetAddonTarballURL function

(t *testing.T)

Source from the content-addressed store, hash-verified

778
779// TestGetAddonTarballURL tests the GetAddonTarballURL function
780func TestGetAddonTarballURL(t *testing.T) {
781 if !github.HasGitHubToken() {
782 t.Skip("Skipping because DDEV_GITHUB_TOKEN is not set")
783 }
784 // The test should succeed without real GitHub tokens
785 // GetAddonTarballURL can call GetGitHubRelease under the hood
786 t.Setenv("DDEV_GITHUB_TOKEN", "dummy-token")
787 t.Setenv("GH_TOKEN", "dummy-token")
788 t.Setenv("GITHUB_TOKEN", "dummy-token")
789
790 tests := []struct {
791 name string
792 ownerRepo string
793 gitRef string
794 defaultBranch bool
795 prNumber int
796 expectedURL string
797 expectedVersion string
798 expectError bool
799 }{
800 {
801 name: "with specific version tag",
802 ownerRepo: "ddev/ddev-redis",
803 gitRef: "v1.2.3",
804 defaultBranch: false,
805 prNumber: 0,
806 expectedURL: "https://github.com/ddev/ddev-redis/tarball/v1.2.3",
807 expectedVersion: "v1.2.3",
808 expectError: false,
809 },
810 {
811 name: "with branch name",
812 ownerRepo: "ddev/ddev-redis",
813 gitRef: "main",
814 defaultBranch: false,
815 prNumber: 0,
816 expectedURL: "https://github.com/ddev/ddev-redis/tarball/main",
817 expectedVersion: "main",
818 expectError: false,
819 },
820 {
821 name: "with commit SHA",
822 ownerRepo: "ddev/ddev-redis",
823 gitRef: "b50ac77",
824 defaultBranch: false,
825 prNumber: 0,
826 expectedURL: "https://github.com/ddev/ddev-redis/tarball/b50ac77",
827 expectedVersion: "b50ac77",
828 expectError: false,
829 },
830 {
831 name: "with PR number",
832 ownerRepo: "ddev/ddev-redis",
833 gitRef: "",
834 defaultBranch: false,
835 prNumber: 54,
836 expectedURL: "https://github.com/ddev/ddev-redis/tarball/refs/pull/54/head",
837 expectedVersion: "pr-54",

Callers

nothing calls this directly

Calls 3

HasGitHubTokenFunction · 0.92
GetAddonTarballURLFunction · 0.92
ErrorMethod · 0.80

Tested by

no test coverage detected