This repository was archived by the owner on Oct 31, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +38
-4
lines changed
packages/plugin-aws-sdk/test Expand file tree Collapse file tree 3 files changed +38
-4
lines changed Original file line number Diff line number Diff line change @@ -217,6 +217,23 @@ describe("plugin-aws-sdk", () => {
217217 ) ;
218218 done ( ) ;
219219 } ) ;
220+
221+ it ( "should create span if no callback is supplied" , ( done ) => {
222+ const s3 = new AWS . S3 ( ) ;
223+ const bucketName = "aws-test-bucket" ;
224+
225+ s3 . putObject ( {
226+ Bucket : bucketName ,
227+ Key : "key name from tests" ,
228+ Body : "Hello World!" ,
229+ } ) . send ( ) ;
230+
231+ setImmediate ( ( ) => {
232+ const awsSpans = getAwsSpans ( ) ;
233+ expect ( awsSpans . length ) . toBe ( 1 ) ;
234+ done ( ) ;
235+ } ) ;
236+ } ) ;
220237 } ) ;
221238
222239 describe ( "send return error" , ( ) => {
Original file line number Diff line number Diff line change @@ -73,6 +73,21 @@ describe("sqs", () => {
7373 } ;
7474
7575 it ( "should set parent context in sqs receive callback" , async ( done ) => {
76+ const sqs = new AWS . SQS ( ) ;
77+ sqs . receiveMessage (
78+ {
79+ QueueUrl : "queue/url/for/unittests" ,
80+ } ,
81+ ( err : AWSError , data : AWS . SQS . Types . ReceiveMessageResult ) => {
82+ expect ( err ) . toBeFalsy ( ) ;
83+ createReceiveChildSpan ( ) ;
84+ expectReceiverWithChildSpan ( memoryExporter . getFinishedSpans ( ) ) ;
85+ done ( ) ;
86+ }
87+ ) ;
88+ } ) ;
89+
90+ it ( "should set parent context in sqs receive 'send' callback" , async ( done ) => {
7691 const sqs = new AWS . SQS ( ) ;
7792 sqs
7893 . receiveMessage ( {
Original file line number Diff line number Diff line change 11import AWS from "aws-sdk" ;
22
33export const mockAwsSend = ( sendResult : any , data : any = undefined ) => {
4- AWS . Request . prototype . send = function ( cb : ( error , response ) => void ) {
5- ( this as AWS . Request < any , any > ) . on ( "complete" , ( response ) => {
6- cb ( response . error , response ) ;
7- } ) ;
4+ AWS . Request . prototype . send = function ( cb ?: ( error , response ) => void ) {
5+ if ( cb ) {
6+ ( this as AWS . Request < any , any > ) . on ( "complete" , ( response ) => {
7+ cb ( response . error , response ) ;
8+ } ) ;
9+ }
810 const response = {
911 ...sendResult ,
1012 data,
You can’t perform that action at this time.
0 commit comments