Skip to content

Commit

Permalink
Further tinkering
Browse files Browse the repository at this point in the history
  • Loading branch information
kibertoad committed Nov 20, 2023
1 parent 205a01b commit ecb607c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,16 @@ describe('SqsPermissionsConsumerMonoSchema', () => {
} as any)

const fakeResolver = consumerErrorResolver as FakeConsumerErrorResolver
await waitAndRetry(() => {
return fakeResolver.handleErrorCallsCount > 0
})
await waitAndRetry(
() => {
return fakeResolver.handleErrorCallsCount > 0
},
20,
30,
)

expect(fakeResolver.handleErrorCallsCount).toBe(1)
expect(fakeResolver.errors[0].message).toContain('"received": "undefined"')
})

it('Non-JSON message in the queue', async () => {
Expand All @@ -79,6 +84,7 @@ describe('SqsPermissionsConsumerMonoSchema', () => {
})

expect(errorCount).toBe(1)
expect(fakeResolver.errors[0].message).toContain('Expected object, received string')
})
})
})
3 changes: 3 additions & 0 deletions packages/sqs/test/fakes/FakeConsumerErrorResolver.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import { SqsConsumerErrorResolver } from '../../lib/errors/SqsConsumerErrorResolver'

export class FakeConsumerErrorResolver extends SqsConsumerErrorResolver {
public errors: Error[]
public handleErrorCallsCount: number
constructor() {
super()

this.handleErrorCallsCount = 0
this.errors = []
}

public override processError(error: unknown) {
this.handleErrorCallsCount++
this.errors.push(error as Error)
return super.processError(error)
}

Expand Down

0 comments on commit ecb607c

Please sign in to comment.