Skip to content

Commit

Permalink
Check number of lines in index integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskim06 committed Mar 14, 2020
1 parent 844b94c commit 7959e23
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions integration_test/index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package integrationtest

import (
"bytes"
"os"
"testing"

Expand Down Expand Up @@ -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")
}
}

Expand All @@ -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))
}
}

0 comments on commit 7959e23

Please sign in to comment.