github.com/mook-as/cf-cli@v7.0.0-beta.28.0.20200120190804-b91c115fae48+incompatible/cf/util/testhelpers/matchers/contain_elements_in_order_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("ContainElementTimes", func() { 10 It("asserts correctly", func() { 11 array := []string{"one", "two", "three", "two", "five"} 12 13 Expect(array).To(ContainElementTimes("two", 2)) 14 }) 15 16 It("handles missing elements", func() { 17 array := []string{"one", "two", "three", "four", "five"} 18 19 Expect(array).To(ContainElementTimes("something-else", 0)) 20 Expect(array).NotTo(ContainElementTimes("something-else", 1)) 21 }) 22 23 It("handles non-string types", func() { 24 type FancyString string 25 26 array := []FancyString{ 27 FancyString("one"), 28 FancyString("two"), 29 FancyString("three"), 30 FancyString("four"), 31 FancyString("five"), 32 } 33 34 Expect(array).To(ContainElementTimes(FancyString("four"), 1)) 35 }) 36 37 It("errors when given bad data", func() { 38 matcher := ContainElementTimesMatcher{Element: 1} 39 _, err := matcher.Match(2) 40 41 Expect(err).To(MatchError("expected an array")) 42 }) 43 })