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

integration_test: Use new helper method #572

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
9 changes: 6 additions & 3 deletions integration_test/install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func TestKrewInstall(t *testing.T) {

test.Krew("install", validPlugin).RunOrFailOutput()
test.AssertExecutableInPATH("kubectl-" + validPlugin)
test.AssertPluginFromIndex(validPlugin, "default")
}

func TestKrewInstallReRun(t *testing.T) {
Expand Down Expand Up @@ -103,6 +104,7 @@ func TestKrewInstall_ExplicitDefaultIndex(t *testing.T) {

test.Krew("install", "default/"+validPlugin).RunOrFail()
test.AssertExecutableInPATH("kubectl-" + validPlugin)
test.AssertPluginFromIndex(validPlugin, "default")
}

func TestKrewInstall_CustomIndex(t *testing.T) {
Expand All @@ -115,6 +117,7 @@ func TestKrewInstall_CustomIndex(t *testing.T) {
test.Krew("index", "add", "foo", test.TempDir().Path("index/"+constants.DefaultIndexName)).RunOrFail()
test.Krew("install", "foo/"+validPlugin).RunOrFail()
test.AssertExecutableInPATH("kubectl-" + validPlugin)
test.AssertPluginFromIndex(validPlugin, "foo")

if err := test.Krew("install", "invalid/"+validPlugin2).Run(); err == nil {
t.Fatal("expected install from invalid index to fail")
Expand All @@ -132,7 +135,7 @@ func TestKrewInstall_Manifest(t *testing.T) {
"--manifest", filepath.Join("testdata", validPlugin+constants.ManifestExtension)).
RunOrFail()
test.AssertExecutableInPATH("kubectl-" + validPlugin)
test.AssertPluginFromIndex(t, "detached", validPlugin)
test.AssertPluginFromIndex(validPlugin, "detached")
}

func TestKrewInstall_ManifestURL(t *testing.T) {
Expand All @@ -147,7 +150,7 @@ func TestKrewInstall_ManifestURL(t *testing.T) {
"--manifest-url", srv+"/"+validPlugin+constants.ManifestExtension).
RunOrFail()
test.AssertExecutableInPATH("kubectl-" + validPlugin)
test.AssertPluginFromIndex(t, "detached", validPlugin)
test.AssertPluginFromIndex(validPlugin, "detached")
}

func TestKrewInstall_ManifestAndArchive(t *testing.T) {
Expand All @@ -161,7 +164,7 @@ func TestKrewInstall_ManifestAndArchive(t *testing.T) {
"--archive", filepath.Join("testdata", fooPlugin+".tar.gz")).
RunOrFail()
test.AssertExecutableInPATH("kubectl-" + fooPlugin)
test.AssertPluginFromIndex(t, "detached", fooPlugin)
test.AssertPluginFromIndex(fooPlugin, "detached")
}

func TestKrewInstall_OnlyArchive(t *testing.T) {
Expand Down
8 changes: 5 additions & 3 deletions integration_test/testutil_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,16 @@ func (it *ITest) AssertExecutableNotInPATH(file string) {

// AssertPluginFromIndex asserts that a receipt exists for the given plugin and
// that it is from the specified index.
func (it *ITest) AssertPluginFromIndex(t *testing.T, indexName, plugin string) {
func (it *ITest) AssertPluginFromIndex(plugin, indexName string) {
it.t.Helper()

receiptPath := environment.NewPaths(it.Root()).PluginInstallReceiptPath(plugin)
r, err := receipt.Load(receiptPath)
if err != nil {
t.Fatalf("error loading receipt: %v", err)
it.t.Fatalf("error loading receipt: %v", err)
}
if r.Status.Source.Name != indexName {
t.Errorf("wanted index '%s', got: '%s'", indexName, r.Status.Source.Name)
it.t.Errorf("wanted index '%s', got: '%s'", indexName, r.Status.Source.Name)
}
}

Expand Down