2015-10-10 07:29:18 +00:00
|
|
|
package flog
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
2015-10-10 16:18:03 +00:00
|
|
|
|
|
|
|
"fmt"
|
|
|
|
"math/rand"
|
|
|
|
"time"
|
2015-10-10 07:29:18 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
2015-10-10 21:21:25 +00:00
|
|
|
func TestNewDiscardingRouter(t *testing.T) {
|
2015-10-10 07:29:18 +00:00
|
|
|
|
2015-10-10 16:18:03 +00:00
|
|
|
randomness := rand.New(rand.NewSource( time.Now().UTC().UnixNano() ))
|
|
|
|
|
|
|
|
|
2015-10-10 21:21:25 +00:00
|
|
|
router := NewDiscardingRouter()
|
2015-10-10 07:29:18 +00:00
|
|
|
if nil == router {
|
|
|
|
t.Errorf("After trying to create a discard router, expected it to be not nil, but was: %v", router)
|
|
|
|
}
|
2015-10-10 16:18:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
message := fmt.Sprint("%x", randomness.Int63n(9999999999))
|
|
|
|
|
|
|
|
context := make(map[string]interface{})
|
|
|
|
limit := randomness.Int63n(30)
|
|
|
|
for i:=int64(0); i<limit; i++ {
|
|
|
|
context[ fmt.Sprintf("%x", randomness.Int63n(1000*limit)) ] = fmt.Sprintf("%x", randomness.Int63n(999999999999999))
|
|
|
|
}
|
|
|
|
|
|
|
|
router.Route(message, context) // Just make sure it doesn't panic or deadlok, by calling this.
|
2015-10-10 07:29:18 +00:00
|
|
|
}
|