Skip to content

Commit

Permalink
Update libbeat/publisher/testing unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
urso committed Jul 19, 2017
1 parent 9572bf0 commit c8bda89
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions libbeat/publisher/testing/testing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,19 @@ import (
"testing"

"github.com/elastic/beats/libbeat/common"
"github.com/elastic/beats/libbeat/publisher/beat"
"github.com/stretchr/testify/assert"
)

var cnt = 0

func testEvent() common.MapStr {
event := common.MapStr{}
event["message"] = "test"
event["idx"] = cnt
func testEvent() beat.Event {
event := beat.Event{
Fields: common.MapStr{
"message": "test",
"idx": cnt,
},
}
cnt++
return event
}
Expand All @@ -21,7 +25,7 @@ func testEvent() common.MapStr {
func TestChanClientPublishEvent(t *testing.T) {
cc := NewChanClient(1)
e1 := testEvent()
cc.PublishEvent(e1)
cc.Publish(e1)
assert.Equal(t, e1, cc.ReceiveEvent())
}

Expand All @@ -30,7 +34,7 @@ func TestChanClientPublishEvents(t *testing.T) {
cc := NewChanClient(1)

e1, e2 := testEvent(), testEvent()
cc.PublishEvents([]common.MapStr{e1, e2})
go cc.PublishAll([]beat.Event{e1, e2})
assert.Equal(t, e1, cc.ReceiveEvent())
assert.Equal(t, e2, cc.ReceiveEvent())
}

0 comments on commit c8bda89

Please sign in to comment.