-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmatcher_test.go
60 lines (46 loc) · 1.48 KB
/
matcher_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package cli_table_matcher_test
import (
. "github.com/wfernandes/CLITableMatcher"
"bytes"
"code.cloudfoundry.org/cli/cf/terminal"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("CLITableMatcher", func() {
var table *terminal.Table
BeforeEach(func() {
table = terminal.NewTable([]string{"Name", "Email"})
table.Add("foo", "foo@email.com")
})
It("returns error if the actual isn't stringable", func() {
result, err := ContainCLITable(table).Match(nil)
Expect(err).To(HaveOccurred())
Expect(result).To(BeFalse())
})
It("matches cli table stringified", func() {
actualTable := terminal.NewTable([]string{"Name", "Email"})
actualTable.Add("foo", "foo@email.com")
var b []byte
actualBuf := bytes.NewBuffer(b)
actualTable.PrintTo(actualBuf)
result, err := ContainCLITable(table).Match(actualBuf.String())
Expect(result).To(BeTrue())
Expect(err).ToNot(HaveOccurred())
})
It("matches cli table", func() {
actualTable := terminal.NewTable([]string{"Name", "Email"})
actualTable.Add("foo", "foo@email.com")
var b []byte
actualBuf := bytes.NewBuffer(b)
actualTable.PrintTo(actualBuf)
Expect(actualBuf.String()).To(ContainCLITable(table))
})
It("does not match cli table", func() {
actualTable := terminal.NewTable([]string{"Name", "Email"})
actualTable.Add("foo", "bar@email.com")
var b []byte
actualBuf := bytes.NewBuffer(b)
actualTable.PrintTo(actualBuf)
Expect(actualBuf.String()).ToNot(ContainCLITable(table))
})
})