github.com/TIBCOSoftware/flogo-lib@v0.5.9/logger/logfactory_test.go (about) 1 package logger 2 3 import ( 4 "math" 5 "sync" 6 "testing" 7 8 "fmt" 9 "github.com/stretchr/testify/assert" 10 ) 11 12 // TestConcurrentGetLoggerOk tests that the GetLogger function is concurrent 13 func TestConcurrentGetLoggerOk(t *testing.T) { 14 w := sync.WaitGroup{} 15 var recovered interface{} 16 //Create factory 17 f := &DefaultLoggerFactory{} 18 19 for r := 0; r < 100000; r++ { 20 w.Add(1) 21 go func(i int) { 22 defer w.Done() 23 defer func() { 24 if r := recover(); r != nil { 25 recovered = r 26 t.Fatal(recovered) 27 } 28 }() 29 loggerName := fmt.Sprintf("logger%f", math.Mod(float64(i), 5)) 30 f.GetLogger(loggerName) 31 }(r) 32 33 } 34 w.Wait() 35 assert.NotNil(t, f, "Recovered not nil, some problem getting logger") 36 }