github.com/moleculer-go/moleculer@v0.3.3/strategy/strategy_suite_test.go (about) 1 package strategy_test 2 3 import ( 4 log "github.com/sirupsen/logrus" 5 6 "github.com/moleculer-go/moleculer/strategy" 7 . "github.com/onsi/ginkgo" 8 . "github.com/onsi/gomega" 9 ) 10 11 var logger = log.WithField("Unit Test", true) 12 13 type SelectorImpl struct { 14 targetNodeID string 15 } 16 17 func (sel SelectorImpl) TargetNodeID() string { 18 return sel.targetNodeID 19 } 20 21 var _ = Describe("Strategy", func() { 22 thisStrategy := strategy.RandomStrategy{} 23 24 list := []strategy.Selector{SelectorImpl{"alpha"}, SelectorImpl{"beta"}, SelectorImpl{"gamma"}, SelectorImpl{"delta"}} 25 26 emptyList := []strategy.Selector{} 27 28 It("Should return a random target node according to strategy", func() { 29 thisNode := thisStrategy.Select(list) 30 Expect(thisNode).Should(Not(BeNil())) 31 }) 32 33 It("Should return a target node according to strategy", func() { 34 thisNode := thisStrategy.Select(emptyList) 35 Expect(thisNode).Should(BeNil()) 36 }) 37 })