Beispiel #1
0
func (suite *ByteQueueSuite) TestPullDelegatesToProcessor() {
	processor := &MockProcessor{}
	processor.On("Pull",
		mock.Anything, "foo", time.Second).
		Return([]byte("bar"), errors.New("error"))

	q := queue.NewBaseQueue(suite.Pool, "foo")
	q.SetProcessor(processor)

	payload, err := q.Pull(time.Second)

	suite.Assert().Equal([]byte("bar"), payload)
	suite.Assert().Equal("error", err.Error())
}
Beispiel #2
0
func (suite *BaseQueueSuite) TestPushDelegatesToProcesor() {
	processor := &MockProcessor{}
	processor.
		On("Push",
			mock.Anything, "foo", []byte("payload")).
		Return(errors.New("error"))

	q := queue.NewBaseQueue(suite.Pool, "foo")
	q.SetProcessor(processor)

	err := q.Push([]byte("payload"))

	suite.Assert().Equal("error", err.Error())
	processor.AssertNumberOfCalls(suite.T(), "Push", 1)
}