...

Source file src/github.com/onsi/gomega/gleak/ignoring_in_backtrace_test.go

Documentation: github.com/onsi/gomega/gleak

     1  package gleak
     2  
     3  import (
     4  	"reflect"
     5  
     6  	"github.com/onsi/gomega/gleak/goroutine"
     7  
     8  	. "github.com/onsi/ginkgo/v2"
     9  	. "github.com/onsi/gomega"
    10  )
    11  
    12  var _ = Describe("IgnoringInBacktrace matcher", func() {
    13  
    14  	It("returns an error for an invalid actual", func() {
    15  		m := IgnoringInBacktrace("foo.bar")
    16  		Expect(m.Match(nil)).Error().To(MatchError(
    17  			"IgnoringInBacktrace matcher expects a Goroutine or *Goroutine.  Got:\n    <nil>: nil"))
    18  	})
    19  
    20  	It("matches", func() {
    21  		type T struct{}
    22  		pkg := reflect.TypeOf(T{}).PkgPath()
    23  		m := IgnoringInBacktrace(pkg + "/goroutine.stacks")
    24  		Expect(m.Match(somefunction())).To(BeTrue())
    25  	})
    26  
    27  	It("returns failure messages", func() {
    28  		m := IgnoringInBacktrace("foo.bar")
    29  		Expect(m.FailureMessage(Goroutine{Backtrace: "abc"})).To(MatchRegexp(
    30  			`Expected\n    <goroutine.Goroutine>: {ID: 0, State: "", TopFunction: "", CreatorFunction: "", BornAt: ""}\nto contain "foo.bar" in the goroutine's backtrace`))
    31  		Expect(m.NegatedFailureMessage(Goroutine{Backtrace: "abc"})).To(MatchRegexp(
    32  			`Expected\n    <goroutine.Goroutine>: {ID: 0, State: "", TopFunction: "", CreatorFunction: "", BornAt: ""}\nnot to contain "foo.bar" in the goroutine's backtrace`))
    33  	})
    34  
    35  })
    36  
    37  func somefunction() Goroutine {
    38  	return goroutine.Current()
    39  }
    40  

View as plain text