...

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

Documentation: github.com/onsi/gomega/gleak

     1  package gleak
     2  
     3  import (
     4  	. "github.com/onsi/ginkgo/v2"
     5  	. "github.com/onsi/gomega"
     6  )
     7  
     8  var _ = Describe("utilities", func() {
     9  
    10  	Context("G(oroutine) descriptions", func() {
    11  
    12  		It("returns an error for actual <nil>", func() {
    13  			Expect(func() { _, _ = G(nil, "foo") }).NotTo(Panic())
    14  			Expect(G(nil, "foo")).Error().To(MatchError("foo matcher expects a Goroutine or *Goroutine.  Got:\n    <nil>: nil"))
    15  		})
    16  
    17  		It("returns an error when passing something that's not a goroutine by any means", func() {
    18  			Expect(func() { _, _ = G("foobar", "foo") }).NotTo(Panic())
    19  			Expect(G("foobar", "foo")).Error().To(MatchError("foo matcher expects a Goroutine or *Goroutine.  Got:\n    <string>: foobar"))
    20  		})
    21  
    22  		It("returns a goroutine", func() {
    23  			actual := Goroutine{ID: 42}
    24  			g, err := G(actual, "foo")
    25  			Expect(err).NotTo(HaveOccurred())
    26  			Expect(g.ID).To(Equal(uint64(42)))
    27  
    28  			g, err = G(&actual, "foo")
    29  			Expect(err).NotTo(HaveOccurred())
    30  			Expect(g.ID).To(Equal(uint64(42)))
    31  		})
    32  
    33  	})
    34  
    35  	It("returns a list of Goroutine IDs in textual format", func() {
    36  		Expect(goids(nil)).To(BeEmpty())
    37  		Expect(goids([]Goroutine{
    38  			{ID: 666},
    39  			{ID: 42},
    40  		})).To(Equal("42, 666"))
    41  		Expect(goids([]Goroutine{
    42  			{ID: 42},
    43  		})).To(Equal("42"))
    44  	})
    45  
    46  })
    47  

View as plain text