github.com/geofffranks/garden-linux@v0.0.0-20160715111146-26c893169cfa/network/bridgemgr/bridge_name_generator_test.go (about) 1 package bridgemgr_test 2 3 import ( 4 "code.cloudfoundry.org/garden-linux/network/bridgemgr" 5 . "github.com/onsi/ginkgo" 6 . "github.com/onsi/gomega" 7 ) 8 9 var _ = Describe("Bridge Name Generator", func() { 10 var ( 11 generator bridgemgr.BridgeNameGenerator 12 ) 13 14 BeforeEach(func() { 15 generator = bridgemgr.NewBridgeNameGenerator("pr-") 16 }) 17 18 It("returns unique names each time it is called", func() { 19 generatedNames := make(map[string]bool) 20 21 for i := 0; i < 100; i++ { 22 name := generator.Generate() 23 generatedNames[name] = true 24 } 25 26 Expect(generatedNames).To(HaveLen(100)) 27 }) 28 29 It("includes the entire prefix as part of the name", func() { 30 name := generator.Generate() 31 Expect(name).To(HavePrefix("pr-")) 32 }) 33 34 It("returns names that are exactly 15 characters", func() { 35 name := generator.Generate() 36 Expect(name).To(HaveLen(15)) 37 38 name = bridgemgr.NewBridgeNameGenerator("p").Generate() 39 Expect(name).To(HaveLen(15)) 40 }) 41 })