Fixed tests

This commit is contained in:
James Mills 2017-08-19 18:26:15 -07:00
parent 8cb2806793
commit e5a771bae3
No known key found for this signature in database
GPG Key ID: AC4C014F1440EBD6

View File

@ -7,17 +7,17 @@ import (
)
func TestMessageBusLen(t *testing.T) {
mb := NewMessageBus()
mb := NewMessageBus(nil)
assert.Equal(t, mb.Len(), 0)
}
func TestMessage(t *testing.T) {
mb := NewMessageBus()
mb := NewMessageBus(nil)
assert.Equal(t, mb.Len(), 0)
topic := "foo"
topic := mb.NewTopic("foo")
expected := Message{Topic: topic, Payload: []byte("bar")}
mb.Put(topic, expected)
mb.Put(expected)
actual, ok := mb.Get(topic)
assert.True(t, ok)
@ -25,31 +25,31 @@ func TestMessage(t *testing.T) {
}
func TestMessageGetEmpty(t *testing.T) {
mb := NewMessageBus()
mb := NewMessageBus(nil)
assert.Equal(t, mb.Len(), 0)
topic := "foo"
topic := mb.NewTopic("foo")
msg, ok := mb.Get(topic)
assert.False(t, ok)
assert.Equal(t, msg, Message{})
}
func BenchmarkMessageBusPut(b *testing.B) {
mb := NewMessageBus()
topic := "foo"
msg := Message{Payload: []byte("foo")}
mb := NewMessageBus(nil)
topic := mb.NewTopic("foo")
msg := Message{Topic: topic, Payload: []byte("foo")}
b.ResetTimer()
for i := 0; i < b.N; i++ {
mb.Put(topic, msg)
mb.Put(msg)
}
}
func BenchmarkMessageBusGet(b *testing.B) {
mb := NewMessageBus()
topic := "foo"
mb := NewMessageBus(nil)
topic := mb.NewTopic("foo")
msg := Message{Payload: []byte("foo")}
for i := 0; i < b.N; i++ {
mb.Put(topic, msg)
mb.Put(msg)
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
@ -58,8 +58,8 @@ func BenchmarkMessageBusGet(b *testing.B) {
}
func BenchmarkMessageBusGetEmpty(b *testing.B) {
mb := NewMessageBus()
topic := "foo"
mb := NewMessageBus(nil)
topic := mb.NewTopic("foo")
b.ResetTimer()
for i := 0; i < b.N; i++ {
mb.Get(topic)
@ -67,12 +67,12 @@ func BenchmarkMessageBusGetEmpty(b *testing.B) {
}
func BenchmarkMessageBusPutGet(b *testing.B) {
mb := NewMessageBus()
topic := "foo"
mb := NewMessageBus(nil)
topic := mb.NewTopic("foo")
msg := Message{Payload: []byte("foo")}
b.ResetTimer()
for i := 0; i < b.N; i++ {
mb.Put(topic, msg)
mb.Put(msg)
mb.Get(topic)
}
}