Skip to content

Commit

Permalink
Improve test
Browse files Browse the repository at this point in the history
  • Loading branch information
bartekn committed Aug 10, 2022
1 parent 408e4a0 commit 4a9f86d
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions services/horizon/internal/ingest/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ func TestStateMachineRunReturnsErrorWhenNextStateIsShutdownWithError(t *testing.
assert.EqualError(t, err, "invalid range: [0, 0]")
}

func TestMaybeVerifyStateGetExpStateInvalidDBErrCancelOrContextCanceled(t *testing.T) {
func TestMaybeVerifyStateGetExpStateInvalidError(t *testing.T) {
historyQ := &mockDBQ{}
system := &system{
historyQ: historyQ,
Expand All @@ -180,13 +180,21 @@ func TestMaybeVerifyStateGetExpStateInvalidDBErrCancelOrContextCanceled(t *testi
defer func() { log = oldLogger }()

historyQ.On("GetExpStateInvalid", system.ctx).Return(false, db.ErrCancelled).Once()
system.maybeVerifyState(0)
system.maybeVerifyState(63)
system.wg.Wait()

historyQ.On("GetExpStateInvalid", system.ctx).Return(false, context.Canceled).Once()
system.maybeVerifyState(0)
system.maybeVerifyState(63)
system.wg.Wait()

logged := done()
assert.Len(t, logged, 0)

// Ensure state verifier does not start also for any other error
historyQ.On("GetExpStateInvalid", system.ctx).Return(false, errors.New("my error")).Once()
system.maybeVerifyState(63)
system.wg.Wait()

historyQ.AssertExpectations(t)
}
func TestMaybeVerifyInternalDBErrCancelOrContextCanceled(t *testing.T) {
Expand Down

0 comments on commit 4a9f86d

Please sign in to comment.