Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add integration tests for krew install with --archive and --manifest options #245

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 49 additions & 1 deletion integration_test/install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,16 @@

package integrationtest

import "testing"
import (
"path/filepath"
"testing"

"sigs.k8s.io/krew/pkg/constants"
)

const (
fooPlugin = "foo"
)

func TestKrewInstall(t *testing.T) {
skipShort(t)
Expand All @@ -25,3 +34,42 @@ func TestKrewInstall(t *testing.T) {
test.WithIndex().Krew("install", validPlugin).RunOrFailOutput()
test.AssertExecutableInPATH("kubectl-" + validPlugin)
}

func TestKrewInstall_Manifest(t *testing.T) {
skipShort(t)

test, cleanup := NewTest(t)
defer cleanup()

test.Krew("install",
"--manifest", filepath.Join("testdata", validPlugin+constants.ManifestExtension)).
RunOrFail()
test.AssertExecutableInPATH("kubectl-" + validPlugin)
}

func TestKrewInstall_ManifestAndArchive(t *testing.T) {
skipShort(t)

test, cleanup := NewTest(t)
defer cleanup()

test.Krew("install",
"--manifest", filepath.Join("testdata", fooPlugin+constants.ManifestExtension),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to address this but: I feel like these small constants are hurting the readability quite a bit, unless needed, we can probably avoid in the future.

"--archive", filepath.Join("testdata", fooPlugin+".tar.gz")).
RunOrFail()
test.AssertExecutableInPATH("kubectl-" + fooPlugin)
}

func TestKrewInstall_OnlyArchiveFails(t *testing.T) {
skipShort(t)

test, cleanup := NewTest(t)
defer cleanup()

err := test.Krew("install",
"--archive", filepath.Join("testdata", fooPlugin+".tar.gz")).
Run()
if err == nil {
t.Errorf("Expected install to fail but was successful")
}
}
Binary file added integration_test/testdata/foo.tar.gz
Binary file not shown.
28 changes: 28 additions & 0 deletions integration_test/testdata/foo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
apiVersion: krew.googlecontainertools.github.com/v1alpha2
kind: Plugin
metadata:
name: foo
spec:
version: "v0.1.0"
shortDescription: A valid plugin for integration tests
platforms:
- uri: https://foo.bar/foo.tar.gz
sha256: 354bad230cdd0966fc8c919476c4e6c7f2078b04a6ff7dead6a811cdc101d31e
bin: foo.sh
files:
- from: ./foo.sh
to: "."
selector:
matchExpressions:
- key: os
operator: In
values: ["darwin", "linux"]
- uri: https://foo.bar/foo.tar.gz
sha256: 354bad230cdd0966fc8c919476c4e6c7f2078b04a6ff7dead6a811cdc101d31e
bin: foo.bat
files:
- from: ./foo.bat
to: "."
selector:
matchLabels:
os: windows
28 changes: 28 additions & 0 deletions integration_test/testdata/konfig.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
apiVersion: krew.googlecontainertools.github.com/v1alpha2
kind: Plugin
metadata:
name: konfig
spec:
version: "v0.2.0"
shortDescription: a plugin in central index with small size
platforms:
- uri: https://github.com/corneliusweig/konfig/releases/download/v0.2.0/bundle.tar.gz
sha256: 7dc7b884ca92e3c9b39f905cc11bcf31e79b9c929741a4383d9ff61414101962
bin: konfig-krew
files:
- from: ./konfig-krew
to: "."
selector:
matchExpressions:
- key: os
operator: In
values: ["darwin", "linux"]
- uri: https://github.com/corneliusweig/konfig/releases/download/v0.2.0/bundle.tar.gz
sha256: 7dc7b884ca92e3c9b39f905cc11bcf31e79b9c929741a4383d9ff61414101962
bin: konfig-krew.exe
files:
- from: ./konfig-krew
to: konfig-krew.exe
selector:
matchLabels:
os: windows