Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanwitt committed Sep 8, 2024
1 parent 0bf34e4 commit d385ec3
Showing 1 changed file with 41 additions and 10 deletions.
51 changes: 41 additions & 10 deletions test/idleQueues.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,12 +379,26 @@ describe('deleteQueue', () => {
})
})

// describe('processQueueSet', () => {
// test('', async () => {
// const opt = getOptionsWithDefaults()
// await processQueueSet('test', 'https://sqs.us-east-1.amazonaws.com/example/test', opt)
// })
// })
describe('processQueueSet', () => {
test('completes execution', async () => {
const options = { prefix: '' }
const opt = getOptionsWithDefaults(options)
const qname = 'testqueue'
const qrl = `https://sqs.us-east-1.amazonaws.com/foobar/${qname}`
const sqsMock = mockClient(sqsClient)
setSQSClient(sqsMock)
sqsMock
.on(GetQueueAttributesCommand)
.resolves({
QueueUrl: qrl,
Attributes: {
ApproximateNumberOfMessages: '1',
ApproximateNumberOfMessagesNotVisible: '0'
}
})
await processQueueSet('test', 'https://sqs.us-east-1.amazonaws.com/example/test', opt)
})
})

describe('stripSuffixes', () => {
test('works for all examples', () => {
Expand All @@ -403,8 +417,25 @@ describe('idleQueues', () => {
await expect(idleQueues([], { prefix: '' })).resolves.toEqual('noQueues')
})

// test('single queue', async () => {
// await qrlCacheSet('test', 'https://sqs.us-east-1.amazonaws.com/example/test')
// await expect(idleQueues(['test'], { prefix: '' })).resolves.toEqual('noQueues')
// })
test('single queue returns expected result', async () => {
const qname = 'testqueue'
const qrl = `https://sqs.us-east-1.amazonaws.com/foobar/${qname}`
const sqsMock = mockClient(sqsClient)
setSQSClient(sqsMock)
sqsMock
.on(GetQueueAttributesCommand)
.resolves({
QueueUrl: qrl,
Attributes: {
ApproximateNumberOfMessages: '1',
ApproximateNumberOfMessagesNotVisible: '0'
}
})
await qrlCacheSet('test', 'https://sqs.us-east-1.amazonaws.com/example/test')
await expect(idleQueues(['test'], { prefix: '' })).resolves.toEqual([{
apiCalls: { SQS: 3, CloudWatch: 0 },
idle: false,
queue: 'test'
}])
})
})

0 comments on commit d385ec3

Please sign in to comment.