diff --git a/.travis.yml b/.travis.yml index 8e2e5e4..7b368b3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,11 +2,6 @@ language: node_js node_js: - '8.11.4' after_success: "./node_modules/.bin/codecov" -env: - global: - - secure: ZX5mghIvXfscTk20MYNzMZ9s2KgOxQR0rHZgzZuTC9R0lz+YkgBM2xfhclvCEeMiG/XMPKMFxMJ0YU+f9LmFGCciZD/DyJ1PH/vuspXen2JvGtQkUO8tdMQKy9ht/u0/Yo0huRef6eqth0tHhd2zZtwuOuep5XZ0RMw4OY4J0tyySfjqMM9+H/jFGNE/Gt069UFdmaGC6xiHt/zum/gGzEdQBoW/s7vJN3+k4yMsXwiS0fwaqL+XtmkL6ykZJFidnLWt85tgTvqogPvx1D7TawTurZIGjJtbfJGYmQEGbxy/PQB9732soip30u3aRqjBTTUf6b1ow3blcsXiOj+p5Yya8unH1DRVIYpNlzgs9qqOlPVTYNqu+m/n/3uASd0CdEchmfR+GNd6id8Zxu7EzlP/SCW7nr0tSxod2cA526+EuYEF3aG3j93mHtF0gXdGDXeKf7OMLWOFEwuyrzbnKNLcMK9vtzSGYnmNKcQWDtPUPfSmlIL/Pacd210bHctc4HHoYSQYYDYaZsVS8JmtsLYkU/9LgqFJO+lAHP1p1rTpTIoaG0FTLh9TyFT11pKZ5kfZLj/n2q6Vsowq2VVZGMjm3EOg6HUvqFFfv4bd658TvbtgwXNqieiHjv0d66XGnkzPgpxxS9oORmlssppevJ99QYnNPbCVXcN4cjDsi9k= - - secure: ROBoDdSfzlNGSAHxdVLirh0yIQnf0DH37ZxmIWnKQDAHAp0qb6UVDLjY/GAoGq5MYFEguXzz7QLFEm3N/mCFUoMSvQV3zSIdANNU6GdVFtOawSYdXxdIGSIwIH7VgyHtY7n0Qbz3zNsgzpHnGyMQ4+9l7gELm3FTKUKclUkaPX4T8bHfavbNPIDPcc8ttnZanRCD0dZ5hFt+SbHDUYbisBxq/v6aDxPwbzc6y3bw7q+CQNj08nzvwIgy/v9cNjAn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Hq6yQYpGU40VKFr+ghFDgp4blTmS8o60qZybk= deploy: provider: npm api_key: $NPM_TOKEN diff --git a/spec/test.spec.js b/spec/test.spec.js index 57cdd9f..f4a4334 100644 --- a/spec/test.spec.js +++ b/spec/test.spec.js @@ -192,14 +192,74 @@ describe('S3Adapter tests', () => { }); }); + let s3; if (process.env.TEST_S3_ACCESS_KEY && process.env.TEST_S3_SECRET_KEY && process.env.TEST_S3_BUCKET) { // Should be initialized from the env - let s3 = new S3Adapter({ + s3 = new S3Adapter({ accessKey: process.env.TEST_S3_ACCESS_KEY, secretKey: process.env.TEST_S3_SECRET_KEY, bucket: process.env.TEST_S3_BUCKET }); - filesAdapterTests.testAdapter("S3Adapter", s3); + } else { + const bucket = 'FAKE_BUCKET'; + + s3 = new S3Adapter({ + accessKey: 'FAKE_ACCESS_KEY', + secretKey: 'FAKE_SECRET_KEY', + bucket, + }); + + const objects = {}; + + s3._s3Client = { + createBucket: callback => setTimeout(callback, 100), + upload: (params, callback) => setTimeout( + () => { + const { Key, Body } = params; + + objects[Key] = Body; + + callback( + null, + { + Location: `https://${bucket}.s3.amazonaws.com/${Key}` + } + ); + }, + 100 + ), + deleteObject: (params, callback) => setTimeout( + () => { + const { Key } = params; + + delete objects[Key]; + + callback(null, {}); + }, + 100 + ), + getObject: (params, callback) => setTimeout( + () => { + const { Key } = params; + + if (objects[Key]) { + callback( + null, + { + Body: Buffer.from(objects[Key], 'utf8') + } + ); + } else { + callback( + new Error('Not found') + ); + } + }, + 100 + ) + }; } + + filesAdapterTests.testAdapter("S3Adapter", s3); })