@@ -4,6 +4,9 @@ import url from 'url'
44import test from 'ava'
55import nock from 'nock'
66import { DateTime } from 'luxon'
7+ import { PublishCommand } from '@aws-sdk/client-sns'
8+ import { ReceiveMessageCommand } from '@aws-sdk/client-sqs'
9+ import { CreateBucketCommand , PutObjectCommand } from '@aws-sdk/client-s3'
710import { getCollectionIds , getItem } from '../helpers/api.js'
811import { handler , resetAssetProxy } from '../../src/lambdas/ingest/index.js'
912import { loadFixture , randomId } from '../helpers/utils.js'
@@ -54,10 +57,11 @@ test('The ingest lambda supports ingesting a collection published to SNS', async
5457 { id : randomId ( 'collection' ) }
5558 )
5659
57- await sns ( ) . publish ( {
60+ const publishCommand = new PublishCommand ( {
5861 TopicArn : ingestTopicArn ,
5962 Message : JSON . stringify ( collection )
6063 } )
64+ await sns ( ) . send ( publishCommand )
6165
6266 await sqsTriggerLambda ( ingestQueueUrl , handler )
6367
@@ -85,23 +89,26 @@ test('The ingest lambda supports ingesting a collection sourced from S3', async
8589 const sourceBucket = randomId ( 'bucket' )
8690 const sourceKey = randomId ( 'key' )
8791
88- await s3 . createBucket ( {
92+ const createBucketCommand = new CreateBucketCommand ( {
8993 Bucket : sourceBucket ,
9094 CreateBucketConfiguration : {
9195 LocationConstraint : 'us-west-2'
9296 }
9397 } )
98+ await s3 . send ( createBucketCommand )
9499
95- await s3 . putObject ( {
100+ const putObjectCommand = new PutObjectCommand ( {
96101 Bucket : sourceBucket ,
97102 Key : sourceKey ,
98103 Body : JSON . stringify ( collection )
99104 } )
105+ await s3 . send ( putObjectCommand )
100106
101- await sns ( ) . publish ( {
107+ const publishCommand2 = new PublishCommand ( {
102108 TopicArn : ingestTopicArn ,
103109 Message : JSON . stringify ( { href : `s3://${ sourceBucket } /${ sourceKey } ` } )
104110 } )
111+ await sns ( ) . send ( publishCommand2 )
105112
106113 await sqsTriggerLambda ( ingestQueueUrl , handler )
107114
@@ -125,10 +132,11 @@ test('The ingest lambda supports ingesting a collection sourced from http', asyn
125132
126133 nock ( 'http://source.local' ) . get ( '/my-file.dat' ) . reply ( 200 , collection )
127134
128- await sns ( ) . publish ( {
135+ const publishCommand3 = new PublishCommand ( {
129136 TopicArn : ingestTopicArn ,
130137 Message : JSON . stringify ( { href : 'http://source.local/my-file.dat' } )
131138 } )
139+ await sns ( ) . send ( publishCommand3 )
132140
133141 await sqsTriggerLambda ( ingestQueueUrl , handler )
134142
@@ -417,11 +425,12 @@ async function emptyPostIngestQueue(t) {
417425 // We recommend waiting for 60 seconds regardless of your queue's size."
418426 let result
419427 do {
420- // eslint-disable-next-line no-await-in-loop
421- result = await sqs ( ) . receiveMessage ( {
428+ const receiveCommand = new ReceiveMessageCommand ( {
422429 QueueUrl : t . context . postIngestQueueUrl ,
423430 WaitTimeSeconds : 1
424431 } )
432+ // eslint-disable-next-line no-await-in-loop
433+ result = await sqs ( ) . send ( receiveCommand )
425434 } while ( result . Message && result . Message . length > 0 )
426435}
427436
0 commit comments