Skip to content

Commit

Permalink
Merge pull request #18 from carolynvs/fix-tests-on-arm
Browse files Browse the repository at this point in the history
Fix tests when run on arm
  • Loading branch information
carolynvs authored Apr 6, 2022
2 parents 1e72d20 + 3854c2a commit 3031296
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
33 changes: 32 additions & 1 deletion pkg/archive/install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ import (
"github.com/stretchr/testify/require"
)

func TestDownloadArchiveToGopathBin(t *testing.T) {
func TestDownloadArchiveToGopathBin_OsReplacement(t *testing.T) {
if runtime.GOARCH != "amd64" {
t.Skipf("skipping test since gh only has binaries for amd64")
}

os.Setenv(mg.VerboseEnv, "true")
err, cleanup := gopath.UseTempGopath()
require.NoError(t, err, "Failed to set up a temporary GOPATH")
Expand Down Expand Up @@ -48,3 +52,30 @@ func TestDownloadArchiveToGopathBin(t *testing.T) {
_, err = exec.LookPath("gh" + xplat.FileExt())
require.NoError(t, err)
}

func TestDownloadArchiveToGopathBin(t *testing.T) {
os.Setenv(mg.VerboseEnv, "true")
err, cleanup := gopath.UseTempGopath()
require.NoError(t, err, "Failed to set up a temporary GOPATH")
defer cleanup()

opts := DownloadArchiveOptions{
DownloadOptions: downloads.DownloadOptions{
UrlTemplate: "https://get.helm.sh/helm-v{{.VERSION}}-{{.GOOS}}-{{.GOARCH}}{{.EXT}}",
Name: "helm",
Version: "3.8.1",
},
ArchiveExtensions: map[string]string{
"linux": ".tar.gz",
"darwin": ".tar.gz",
"windows": ".zip",
},
TargetFileTemplate: "{{.GOOS}}-{{.GOARCH}}/helm{{.EXT}}",
}

err = DownloadToGopathBin(opts)
require.NoError(t, err)

_, err = exec.LookPath("helm" + xplat.FileExt())
require.NoError(t, err)
}
4 changes: 2 additions & 2 deletions pkg/install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ func TestDownloadToGopathBin(t *testing.T) {
require.NoError(t, err, "Failed to set up a temporary GOPATH")
defer cleanup()

url := "https://storage.googleapis.com/kubernetes-release/release/{{.VERSION}}/bin/{{.GOOS}}/{{.GOARCH}}/kubectl{{.EXT}}"
err = DownloadToGopathBin(url, "kubectl", "v1.19.0")
url := "https://dl.k8s.io/release/{{.VERSION}}/bin/{{.GOOS}}/{{.GOARCH}}/kubectl{{.EXT}}"
err = DownloadToGopathBin(url, "kubectl", "v1.23.0")
require.NoError(t, err)

_, err = exec.LookPath("kubectl" + xplat.FileExt())
Expand Down

0 comments on commit 3031296

Please sign in to comment.