Skip to content

Commit f677975

Browse files
committed
Update tests for AWS SDK v3
1 parent 553d4b5 commit f677975

File tree

3 files changed

+35
-22
lines changed

3 files changed

+35
-22
lines changed

test/fetchMessage.js

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
var assert = require("assert");
55

6+
const {GetObjectCommand, CopyObjectCommand} = require('@aws-sdk/client-s3');
7+
68
var index = require("../index");
79

810
describe('index.js', function() {
@@ -25,11 +27,17 @@ describe('index.js', function() {
2527
},
2628
log: console.log,
2729
s3: {
28-
copyObject: function(options, callback) {
29-
callback(null);
30-
},
31-
getObject: function(options, callback) {
32-
callback(null, {Body: "email data"});
30+
send: function(options, callback) {
31+
if (options instanceof CopyObjectCommand)
32+
callback(null);
33+
else if (options instanceof GetObjectCommand)
34+
callback(null, {
35+
Body: {
36+
transformToString: function() {
37+
return "email data";
38+
}
39+
}
40+
});
3341
}
3442
}
3543
};
@@ -55,10 +63,7 @@ describe('index.js', function() {
5563
},
5664
log: console.log,
5765
s3: {
58-
copyObject: function(options, callback) {
59-
callback(true);
60-
},
61-
getObject: function(options, callback) {
66+
send: function(options, callback) {
6267
callback(true);
6368
}
6469
}
@@ -83,11 +88,11 @@ describe('index.js', function() {
8388
},
8489
log: console.log,
8590
s3: {
86-
copyObject: function(options, callback) {
87-
callback(null);
88-
},
89-
getObject: function(options, callback) {
90-
callback(true);
91+
send: function(options, callback) {
92+
if (options instanceof CopyObjectCommand)
93+
callback(null);
94+
else if (options instanceof GetObjectCommand)
95+
callback(true);
9196
}
9297
}
9398
};

test/handler.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
var assert = require("assert");
55
var fs = require("fs");
66

7+
const {GetObjectCommand, CopyObjectCommand} = require('@aws-sdk/client-s3');
8+
79
var index = require("../index");
810

911
describe('index.js', function() {
@@ -16,15 +18,21 @@ describe('index.js', function() {
1618
};
1719
var overrides = {
1820
s3: {
19-
copyObject: function(options, callback) {
20-
callback(null);
21-
},
22-
getObject: function(options, callback) {
23-
callback(null, {Body: "email data"});
21+
send: function(options, callback) {
22+
if (options instanceof CopyObjectCommand)
23+
callback(null);
24+
else if (options instanceof GetObjectCommand)
25+
callback(null, {
26+
Body: {
27+
transformToString: function() {
28+
return "email data";
29+
}
30+
}
31+
});
2432
}
2533
},
2634
ses: {
27-
sendRawEmail: function(options, callback) {
35+
send: function(options, callback) {
2836
callback(null, {status: "ok"});
2937
}
3038
},

test/sendMessage.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ describe('index.js', function() {
2020
context: {},
2121
log: console.log,
2222
ses: {
23-
sendRawEmail: function(options, callback) {
23+
send: function(options, callback) {
2424
callback(null, {status: "ok"});
2525
}
2626
}
@@ -45,7 +45,7 @@ describe('index.js', function() {
4545
context: {},
4646
log: console.log,
4747
ses: {
48-
sendRawEmail: function(options, callback) {
48+
send: function(options, callback) {
4949
callback(true);
5050
}
5151
}

0 commit comments

Comments
 (0)