github.com/mook-as/cf-cli@v7.0.0-beta.28.0.20200120190804-b91c115fae48+incompatible/util/randomword/generator_test.go (about)

     1  package randomword_test
     2  
     3  import (
     4  	. "code.cloudfoundry.org/cli/util/randomword"
     5  
     6  	. "github.com/onsi/ginkgo"
     7  	. "github.com/onsi/gomega"
     8  )
     9  
    10  var _ = Describe("Generator", func() {
    11  	var gen Generator = NewGenerator()
    12  
    13  	Describe("RandomAdjective", func() {
    14  		It("generates a random adjective each time it is called", func() {
    15  			Eventually(gen.RandomAdjective).ShouldNot(Equal(gen.RandomAdjective()))
    16  		})
    17  	})
    18  
    19  	Describe("RandomNoun", func() {
    20  		It("generates a random noun each time it is called", func() {
    21  			Eventually(gen.RandomNoun).ShouldNot(Equal(gen.RandomNoun()))
    22  		})
    23  	})
    24  
    25  	Describe("RandomTwoLetters", func() {
    26  		It("generates a random string each time it is called", func() {
    27  			Eventually(gen.RandomTwoLetters).ShouldNot(Equal(gen.RandomTwoLetters()))
    28  		})
    29  		It("generates a two letter string", func() {
    30  			Expect(gen.RandomTwoLetters()).To(MatchRegexp(`^[a-z]{2}$`))
    31  		})
    32  	})
    33  
    34  	Describe("Babble", func() {
    35  		It("generates a random adjective noun pair each time it is called", func() {
    36  			wordPair := gen.Babble()
    37  			Expect(wordPair).To(MatchRegexp(`^\w+-\w+-[a-z]{2}$`))
    38  		})
    39  	})
    40  })