示例#1
0
func (suite *ByteQueueSuite) TestConcatAbortsOnTooManyErrors() {
	err := errors.New("some net error or something")
	processor := &MockProcessor{}
	processor.On("Concat",
		mock.Anything, "bar", "foo").
		Return(err).Times(3)

	q := queue.NewByteQueue(suite.Pool, "foo")

	q.SetProcessor(processor)
	suite.Assert().Equal(q.Concat("bar"), err)

	processor.AssertExpectations(suite.T())
}
示例#2
0
func (suite *ByteQueueSuite) TestConcatAbortsOnCommandError() {
	err := redis.Error("oh no!")
	processor := &MockProcessor{}
	processor.On("Concat",
		mock.Anything, "bar", "foo").
		Return(err).Once()

	q := queue.NewByteQueue(suite.Pool, "foo")

	q.SetProcessor(processor)
	suite.Assert().Equal(q.Concat("bar"), err)

	processor.AssertExpectations(suite.T())
}
示例#3
0
func (suite *ByteQueueSuite) TestConcatRetriesOnCnxError() {
	processor := &MockProcessor{}
	processor.On("Concat",
		mock.Anything, "bar", "foo").
		Return(errors.New("some net error or something")).Once()
	processor.On("Concat",
		mock.Anything, "bar", "foo").
		Return(redis.ErrNil).Once()

	q := queue.NewByteQueue(suite.Pool, "foo")

	q.SetProcessor(processor)
	suite.Assert().Nil(q.Concat("bar"))

	processor.AssertExpectations(suite.T())
}
示例#4
0
func (suite *ByteQueueSuite) TestConcatsDelegatesToProcessor() {
	processor := &MockProcessor{}
	processor.On("Concat",
		mock.Anything, "bar", "foo").
		Return(nil).Once()
	processor.On("Concat",
		mock.Anything, "bar", "foo").
		Return(redis.ErrNil).Once()

	q := queue.NewByteQueue(suite.Pool, "foo")

	q.SetProcessor(processor)
	suite.Assert().Nil(q.Concat("bar"))

	processor.AssertExpectations(suite.T())
}
示例#5
0
func (suite *ByteQueueSuite) TestConstruction() {
	q := queue.NewByteQueue(suite.Pool, "foo")

	suite.Assert().IsType(&queue.ByteQueue{}, q)
}