From 7959e2398572236b16da5c3a5e087c2f114ef113 Mon Sep 17 00:00:00 2001 From: Chris Kim Date: Fri, 13 Mar 2020 19:05:56 -0700 Subject: [PATCH] Check number of lines in index integration test --- integration_test/index_test.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/integration_test/index_test.go b/integration_test/index_test.go index 8742ddf5..31514192 100644 --- a/integration_test/index_test.go +++ b/integration_test/index_test.go @@ -15,7 +15,6 @@ package integrationtest import ( - "bytes" "os" "testing" @@ -53,15 +52,17 @@ func TestKrewIndexList(t *testing.T) { defer cleanup() test.WithEnv(constants.EnableMultiIndexSwitch, 1).WithIndex() - out := string(test.Krew("index", "list").RunOrFailOutput()) - if !bytes.Contains(out, []byte(constants.DefaultIndexName)) { - t.Fatalf("expected index 'default' in output:\n%s", string(out)) + out := test.Krew("index", "list").RunOrFailOutput() + if indexes := lines(out); len(indexes) < 2 { + // the first line is the header + t.Fatal("expected at least 1 index in output") } test.Krew("index", "add", "foo", test.TempDir().Path("index/"+constants.DefaultIndexName)).RunOrFail() out = test.Krew("index", "list").RunOrFailOutput() - if !bytes.Contains(out, []byte("foo")) { - t.Fatalf("expected index 'foo' in output:\n%s", string(out)) + if indexes := lines(out); len(indexes) < 3 { + // the first line is the header + t.Fatal("expected 2 indexes in output") } } @@ -78,7 +79,8 @@ func TestKrewIndexList_NoIndexes(t *testing.T) { } out := test.Krew("index", "list").RunOrFailOutput() - if !bytes.Equal(out, []byte("INDEX URL\n")) { + if indexes := lines(out); len(indexes) > 1 { + // the first line is the header t.Fatalf("expected index list to be empty:\n%s", string(out)) } }