diff --git a/integration_test/install_test.go b/integration_test/install_test.go index a3b3580e..668f602c 100644 --- a/integration_test/install_test.go +++ b/integration_test/install_test.go @@ -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) @@ -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), + "--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") + } +} diff --git a/integration_test/testdata/foo.tar.gz b/integration_test/testdata/foo.tar.gz new file mode 100644 index 00000000..c0e61a1b Binary files /dev/null and b/integration_test/testdata/foo.tar.gz differ diff --git a/integration_test/testdata/foo.yaml b/integration_test/testdata/foo.yaml new file mode 100644 index 00000000..98711e64 --- /dev/null +++ b/integration_test/testdata/foo.yaml @@ -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 diff --git a/integration_test/testdata/konfig.yaml b/integration_test/testdata/konfig.yaml new file mode 100644 index 00000000..a8a33f6f --- /dev/null +++ b/integration_test/testdata/konfig.yaml @@ -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