github.com/onsi/gomega@v1.32.0/gleak/ignoring_goroutines_test.go (about) 1 package gleak 2 3 import ( 4 . "github.com/onsi/ginkgo/v2" 5 . "github.com/onsi/gomega" 6 ) 7 8 var _ = Describe("IgnoringGoroutines matcher", func() { 9 10 It("returns an error for an invalid actual", func() { 11 m := IgnoringGoroutines(Goroutines()) 12 Expect(m.Match(nil)).Error().To(MatchError( 13 "IgnoringGoroutines matcher expects a Goroutine or *Goroutine. Got:\n <nil>: nil")) 14 }) 15 16 It("matches", func() { 17 gs := Goroutines() 18 me := gs[0] 19 m := IgnoringGoroutines(gs) 20 Expect(m.Match(me)).To(BeTrue()) 21 Expect(m.Match(gs[1])).To(BeTrue()) 22 Expect(m.Match(Goroutine{})).To(BeFalse()) 23 }) 24 25 It("returns failure messages", func() { 26 m := IgnoringGoroutines(Goroutines()) 27 Expect(m.FailureMessage(Goroutine{})).To(MatchRegexp( 28 `Expected\n <goroutine.Goroutine>: {ID: 0, State: "", TopFunction: "", CreatorFunction: "", BornAt: ""}\nto be contained in the list of expected goroutine IDs\n <\[\]uint64 | len:\d+, cap:\d+>: [.*]`)) 29 Expect(m.NegatedFailureMessage(Goroutine{})).To(MatchRegexp( 30 `Expected\n <goroutine.Goroutine>: {ID: 0, State: "", TopFunction: "", CreatorFunction: "", BornAt: ""}\nnot to be contained in the list of expected goroutine IDs\n <\[\]uint64 | len:\d+, cap:\d+>: [.*]`)) 31 }) 32 33 })