Skip to content

Commit

Permalink
Fix tests when run on arm
Browse files Browse the repository at this point in the history
Some of the test cases didn't have compiled binaries for arm. I've updated some tests to skip (since they exercised interesting test cases for template replacements) and updated others to more recent versions with arm binaries available.

Signed-off-by: Carolyn Van Slyck <me@carolynvanslyck.com>
  • Loading branch information
carolynvs committed Apr 6, 2022
1 parent 860df83 commit 3854c2a
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 3854c2a

Please sign in to comment.