github.com/loggregator/cli@v6.33.1-0.20180224010324-82334f081791+incompatible/util/randomword/generator_test.go (about) 1 package randomword_test 2 3 import ( 4 "time" 5 6 . "code.cloudfoundry.org/cli/util/randomword" 7 8 . "github.com/onsi/ginkgo" 9 . "github.com/onsi/gomega" 10 ) 11 12 var _ = Describe("Generator", func() { 13 var gen Generator 14 15 BeforeEach(func() { 16 gen = Generator{} 17 }) 18 19 Describe("RandomAdjective", func() { 20 It("generates a random adjective each time it is called", func() { 21 adj := gen.RandomAdjective() 22 // We wait for 3 millisecond because the seed we use to generate the 23 // randomness has a unit of 1 nanosecond plus random test flakiness 24 time.Sleep(3) 25 Expect(adj).ToNot(Equal(gen.RandomAdjective())) 26 }) 27 }) 28 29 Describe("RandomNoun", func() { 30 It("generates a random noun each time it is called", func() { 31 noun := gen.RandomNoun() 32 // We wait for 3 millisecond because the seed we use to generate the 33 // randomness has a unit of 1 nanosecond plus random test flakiness 34 time.Sleep(10) 35 Expect(noun).ToNot(Equal(gen.RandomNoun())) 36 }) 37 }) 38 39 Describe("Babble", func() { 40 It("generates a random adjective noun pair each time it is called", func() { 41 wordPair := gen.Babble() 42 Expect(wordPair).To(MatchRegexp("^\\w+-\\w+$")) 43 }) 44 }) 45 })