154cc9eb4f
timestamp approach does not work because the update test modifies the version info file
51 lines
1.5 KiB
JavaScript
51 lines
1.5 KiB
JavaScript
/* jslint node: true */
|
|
|
|
'use strict';
|
|
|
|
var assert = require('assert'),
|
|
debug = require('debug')('e2e:mailer'),
|
|
postmark = require('postmark')(process.env.POSTMARK_API_KEY_TOOLS),
|
|
util = require('util');
|
|
|
|
exports = module.exports = {
|
|
sendEndToEndTestResult: sendEndToEndTestResult
|
|
};
|
|
|
|
function send(options, callback) {
|
|
assert.strictEqual(typeof options, 'object');
|
|
assert.strictEqual(typeof options.to, 'string');
|
|
assert.strictEqual(typeof options.subject, 'string');
|
|
assert.strictEqual(typeof options.text, 'string');
|
|
|
|
debug('Sending email to %s with subject "%s".', options.to, options.subject);
|
|
|
|
postmark.send({
|
|
'From': options.from || 'no-reply@cloudron.io',
|
|
'To': options.to,
|
|
'Bcc': options.bcc,
|
|
'Subject': options.subject,
|
|
'TextBody': options.text,
|
|
'HtmlBody': options.html,
|
|
'Tag': 'Important'
|
|
}, function (error, success) {
|
|
if (error) {
|
|
console.error('Unable to send via postmark: ', error);
|
|
return callback(error);
|
|
}
|
|
|
|
callback();
|
|
});
|
|
}
|
|
|
|
function sendEndToEndTestResult(topic, versionInfo, stdout, stderr, callback) {
|
|
debug('Sending e2e test result for %s', topic);
|
|
|
|
var mailOptions = {
|
|
to: 'admin@cloudron.io',
|
|
subject: util.format('E2E test results for %s', topic),
|
|
text: versionInfo + '\n\nstdout\n------\n' + stdout.toString('utf8') + '\n\nstderr\n------\n' + stderr.toString('utf8') + '\n\n'
|
|
};
|
|
|
|
send(mailOptions, callback);
|
|
}
|