/**
     * @param {S3StorageServiceFactoryConfig} config
     * @param {string} basePath
     */
    static createLocalstorageS3Client(config, basePath) {
        AWSMock.config.basePath = Path.join(basePath, config.localConfig.path).replace(/\/$/,'');

        if (config.bucket) {
            return AWSMock.S3({
                params: { Bucket: config.bucket }
            });
        } else {
            return AWSMock.S3();
        }
    }
Ejemplo n.º 2
0
test('[aggregate] start mocking S3 client', function(assert) {
  Client = AWS.S3;
  AWS.S3 = function() {};
  AWS.S3.prototype = mock.S3();
  AWS.S3.prototype.getObject = function(params, callback) {
    mock.S3().getObject(params, callback);
    return new events.EventEmitter();
  };
  assert.end();
});
Ejemplo n.º 3
0
var Dynalite = require('dynalite');
var Cardboard = require('../');
var fakeAWS = require('mock-aws-s3');
var queue = require('queue-async');
var dynalite;

var config = module.exports.config = {
    accessKeyId: 'fake',
    secretAccessKey: 'fake',
    table: 'geo',
    endpoint: 'http://localhost:4567',
    bucket: 'test',
    prefix: 'test',
    region: 'us-east-1',
    s3: fakeAWS.S3() // only for mocking s3
};

var dyno = module.exports.dyno = require('dyno')(config);

module.exports.setup = function(t, multi) {
    dynalite = Dynalite({
        createTableMs: 0,
        updateTableMs: 0,
        deleteTableMs: 0
    });
    dynalite.listen(4567, function() {
        t.pass('dynalite listening');
        var cardboard = Cardboard(config);
        var q = queue(1);

        q.defer(cardboard.createTable, config.table);
Ejemplo n.º 4
0
 AWS.S3.prototype.getObject = function(params, callback) {
   mock.S3().getObject(params, callback);
   return new events.EventEmitter();
 };
Ejemplo n.º 5
0
'use strict';

const debug = require('debug')('hello-helper');
const AWS = require('mock-aws-s3');

AWS.config.basePath = __dirname + '/buckets';

const s3 = AWS.S3({ params: { Bucket: 'example' } });

function surprise(name) {
    if (Math.floor(Math.random() * 100) + 1 <= 50) {
        return new Error(`w00t!!! ${name} error`);
    }
}

function sendSmsRetryable(trial, data, callback) {
    setTimeout(() => {
        if (trial > 1) {
            debug(`${trial} trial left, sending out sms: ${JSON.stringify(data)}`);
            if (surprise('sending-sms')) {
                sendSmsRetryable(trial-1, data, callback);
            }
        } else {
            callback(surprise('sending-sms'), {
                status: 200,
                message: 'OK',
            });
        }
    }, 200);  
}