github.com/mook-as/cf-cli@v7.0.0-beta.28.0.20200120190804-b91c115fae48+incompatible/cf/util/testhelpers/matchers/contain_element_times_test.go (about) 1 package matchers_test 2 3 import ( 4 . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" 5 . "github.com/onsi/ginkgo" 6 . "github.com/onsi/gomega" 7 ) 8 9 var _ = Describe("ContainElementsInOrder", func() { 10 It("asserts correctly", func() { 11 array := []string{"one", "two", "three", "four", "five"} 12 13 Expect(array).To(ContainElementsInOrder("two", "four")) 14 }) 15 16 It("handles out-of-order elements", func() { 17 array := []string{"one", "two", "three", "four", "five"} 18 19 Expect(array).NotTo(ContainElementsInOrder("four", "two")) 20 }) 21 22 It("handles missing elements", func() { 23 array := []string{"one", "two", "three", "four", "five"} 24 25 Expect(array).NotTo(ContainElementsInOrder("something-else")) 26 }) 27 28 It("handles non-string types", func() { 29 type FancyString string 30 31 array := []FancyString{ 32 FancyString("one"), 33 FancyString("two"), 34 FancyString("three"), 35 FancyString("four"), 36 FancyString("five"), 37 } 38 39 Expect(array).To(ContainElementsInOrder(FancyString("one"), FancyString("four"))) 40 }) 41 42 It("errors when given bad data", func() { 43 array := []string{"1", "2"} 44 matcher := ContainElementsInOrderMatcher{Elements: array} 45 _, err := matcher.Match(2) 46 47 Expect(err).To(MatchError("expected an array")) 48 }) 49 })