Skip to content
This repository has been archived by the owner on Feb 18, 2021. It is now read-only.

Commit

Permalink
Fix mocks issue with startFrom test
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillaume Bailey committed Mar 25, 2017
1 parent 7e89bd5 commit 6fe0162
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions services/frontendhost/frontend_test.go
Expand Up @@ -784,7 +784,7 @@ func (s *FrontendHostSuite) TestFrontendHostCreateConsumerGroup() {
// TestFrontendHostCreateConsumerGroupStartFrom tests whether CreateConsumerGroup is able to
// detect and appropriately convert various startFrom units.
func (s *FrontendHostSuite) TestFrontendHostCreateConsumerGroupStartFrom() {

defer s.resetMocks()
testPath := uuid.New()
testCG := s.generateKey("/bar/CGName")
frontendHost, ctx := s.utilGetContextAndFrontend()
Expand All @@ -807,16 +807,15 @@ func (s *FrontendHostSuite) TestFrontendHostCreateConsumerGroupStartFrom() {
DestinationUUID: common.StringPtr(uuid.New()),
}

if !willError {
// create destination is needed because of dlq destination been created at time of consumer group creation
s.mockController.On("CreateDestination", mock.Anything, mock.Anything).Return(destDesc, nil).Run(func(args mock.Arguments) {
s.Equal(dlqPath, args.Get(1).(*shared.CreateDestinationRequest).GetPath())
})
s.resetMocks()
// create destination is needed because of dlq destination been created at time of consumer group creation
s.mockController.On("CreateDestination", mock.Anything, mock.Anything).Return(destDesc, nil).Run(func(args mock.Arguments) {
s.Equal(dlqPath, args.Get(1).(*shared.CreateDestinationRequest).GetPath())
})

s.mockController.On("CreateConsumerGroup", mock.Anything, mock.Anything).Once().Return(cgDesc, nil).Run(func(args mock.Arguments) {
startFromReturn = args.Get(1).(*shared.CreateConsumerGroupRequest).GetStartFrom()
})
}
s.mockController.On("CreateConsumerGroup", mock.Anything, mock.Anything).Once().Return(cgDesc, nil).Run(func(args mock.Arguments) {
startFromReturn = args.Get(1).(*shared.CreateConsumerGroupRequest).GetStartFrom()
})

// set startFrom to the test value (of varying units)
req.StartFrom = common.Int64Ptr(startFrom)
Expand Down

0 comments on commit 6fe0162

Please sign in to comment.