Skip to content

Commit

Permalink
Update tests for AWS SDK v3
Browse files Browse the repository at this point in the history
  • Loading branch information
mylesboone committed Oct 19, 2023
1 parent 5c3dc02 commit dbf70d7
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 22 deletions.
33 changes: 19 additions & 14 deletions test/fetchMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

var assert = require("assert");

const {GetObjectCommand, CopyObjectCommand} = require('@aws-sdk/client-s3');

var index = require("../index");

describe('index.js', function() {
Expand All @@ -25,11 +27,17 @@ describe('index.js', function() {
},
log: console.log,
s3: {
copyObject: function(options, callback) {
callback(null);
},
getObject: function(options, callback) {
callback(null, {Body: "email data"});
send: function(options, callback) {
if (options instanceof CopyObjectCommand)
callback(null);
else if (options instanceof GetObjectCommand)
callback(null, {
Body: {
transformToString: function() {
return "email data";
}
}
});
}
}
};
Expand All @@ -55,10 +63,7 @@ describe('index.js', function() {
},
log: console.log,
s3: {
copyObject: function(options, callback) {
callback(true);
},
getObject: function(options, callback) {
send: function(options, callback) {
callback(true);
}
}
Expand All @@ -83,11 +88,11 @@ describe('index.js', function() {
},
log: console.log,
s3: {
copyObject: function(options, callback) {
callback(null);
},
getObject: function(options, callback) {
callback(true);
send: function(options, callback) {
if (options instanceof CopyObjectCommand)
callback(null);
else if (options instanceof GetObjectCommand)
callback(true);
}
}
};
Expand Down
20 changes: 14 additions & 6 deletions test/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
var assert = require("assert");
var fs = require("fs");

const {GetObjectCommand, CopyObjectCommand} = require('@aws-sdk/client-s3');

var index = require("../index");

describe('index.js', function() {
Expand All @@ -16,15 +18,21 @@ describe('index.js', function() {
};
var overrides = {
s3: {
copyObject: function(options, callback) {
callback(null);
},
getObject: function(options, callback) {
callback(null, {Body: "email data"});
send: function(options, callback) {
if (options instanceof CopyObjectCommand)
callback(null);
else if (options instanceof GetObjectCommand)
callback(null, {
Body: {
transformToString: function() {
return "email data";
}
}
});
}
},
ses: {
sendRawEmail: function(options, callback) {
send: function(options, callback) {
callback(null, {status: "ok"});
}
},
Expand Down
4 changes: 2 additions & 2 deletions test/sendMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('index.js', function() {
context: {},
log: console.log,
ses: {
sendRawEmail: function(options, callback) {
send: function(options, callback) {
callback(null, {status: "ok"});
}
}
Expand All @@ -45,7 +45,7 @@ describe('index.js', function() {
context: {},
log: console.log,
ses: {
sendRawEmail: function(options, callback) {
send: function(options, callback) {
callback(true);
}
}
Expand Down

0 comments on commit dbf70d7

Please sign in to comment.