Skip to content
This repository has been archived by the owner on Sep 2, 2021. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Updated Node version to 6.9.5 and also AWS S3 API (#74)
* Updated AWS S3 API which works with the newer node versions

* Fixed failing tests

* Updated the node version for travis

* Fixed travis build error

* Upgraded Node version to 6.9.5

* Removed redundant arguments in spec functions
  • Loading branch information
saurabh95 authored and swmitra committed Feb 23, 2017
1 parent 94ee4c8 commit 5906d0f
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 123 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
@@ -1,6 +1,6 @@
language: node_js
node_js:
- "0.10"
- "6.9.5"

script:
- npm test
6 changes: 3 additions & 3 deletions downloadStats/logfileProcessor.js
Expand Up @@ -94,7 +94,7 @@ LogfileProcessor.prototype = {
setLastProcessedKey: function (lastAccessedKey) {
var self = this;

var s3 = new AWS.S3.Client({
var s3 = new AWS.S3({
sslEnabled: true
});

Expand Down Expand Up @@ -126,7 +126,7 @@ LogfileProcessor.prototype = {
getLastProcessedKey: function () {
var self = this;

var s3 = new AWS.S3.Client({
var s3 = new AWS.S3({
sslEnabled: true
});

Expand Down Expand Up @@ -160,7 +160,7 @@ LogfileProcessor.prototype = {
_downloadLogfiles: function (tempFolderName, lastProcessedKey) {
var self = this;

var s3 = new AWS.S3.Client({
var s3 = new AWS.S3({
sslEnabled: true
});

Expand Down
6 changes: 3 additions & 3 deletions lib/s3storage.js
Expand Up @@ -76,7 +76,7 @@ S3Storage.prototype = {

this._registrySaveInProgress = true;

var s3 = new AWS.S3.Client({
var s3 = new AWS.S3({
sslEnabled: true
});

Expand Down Expand Up @@ -130,7 +130,7 @@ S3Storage.prototype = {
* @param <Function> callback function that is called with error, if any
*/
savePackage: function (entry, path, callback) {
var s3 = new AWS.S3.Client({
var s3 = new AWS.S3({
sslEnabled: true
});

Expand Down Expand Up @@ -166,7 +166,7 @@ S3Storage.prototype = {
* @param <Function> callback(err, registry)
*/
getRegistry: function (callback) {
var s3 = new AWS.S3.Client({
var s3 = new AWS.S3({
sslEnabled: true
});
s3.getObject({
Expand Down
1 change: 0 additions & 1 deletion package.json
Expand Up @@ -27,7 +27,6 @@
"passport-github": "~0.1.5",
"semver": "2.x",
"aws-sdk": "~2.0.0-rc9",
"brackets-extensibility": ">0.31.0",
"replify": "~1.1.4",
"clone": "~0.1.9",
"rss": "0.2.1",
Expand Down
8 changes: 2 additions & 6 deletions spec/logfileProcessor.spec.js
Expand Up @@ -103,9 +103,7 @@ describe("LogfileProcessor", function () {
config: {
update: jasmine.createSpy()
},
S3: {
Client: function (arg) { return S3; }
}
S3: function () { return S3; }
};

logfileProcessor.__set__("AWS", AWS);
Expand Down Expand Up @@ -158,9 +156,7 @@ describe("LogfileProcessor", function () {
config: {
update: jasmine.createSpy()
},
S3: {
Client: function (arg) { return s3; }
}
S3: function () { return s3; }
};

return AWS;
Expand Down
203 changes: 94 additions & 109 deletions spec/storage.spec.js
Expand Up @@ -111,11 +111,9 @@ describe("S3 Storage", function () {
callback(null, result);
};

AWS.S3 = {
Client: function (options) {
expect(options.sslEnabled).toEqual(true);
this.getObject = getObject;
}
AWS.S3 = function (options) {
expect(options.sslEnabled).toEqual(true);
this.getObject = getObject;
};

storage.getRegistry(function (err, registry) {
Expand All @@ -135,10 +133,8 @@ describe("S3 Storage", function () {
});
};

AWS.S3 = {
Client: function (options) {
this.getObject = getObject;
}
AWS.S3 = function (options) {
this.getObject = getObject;
};

var logging = s3storage.__get__("logging");
Expand All @@ -158,29 +154,26 @@ describe("S3 Storage", function () {

var requestNumber = 1;

AWS.S3 = {
Client: function (options) {
this.putObject = function (params, callback) {
if (requestNumber === 1) {
requestNumber++;

expect(params).toEqual({
Bucket: "repository.brackets.io",
Key: "registry.json",
ACL: "public-read",
ContentEncoding: "gzip",
ContentType: "application/json",
Body: jasmine.any(Buffer)
});
AWS.S3 = function (options) {
this.putObject = function (params, callback) {
if (requestNumber === 1) {
requestNumber++;
expect(params).toEqual({
Bucket: "repository.brackets.io",
Key: "registry.json",
ACL: "public-read",
ContentEncoding: "gzip",
ContentType: "application/json",
Body: jasmine.any(Buffer)
});

zlib.gunzip(params.Body, function (err, uncompressed) {
var registry = JSON.parse(uncompressed.toString());
expect(registry).toEqual(sampleRegistry);
done();
});
}
};
}
zlib.gunzip(params.Body, function (err, uncompressed) {
var registry = JSON.parse(uncompressed.toString());
expect(registry).toEqual(sampleRegistry);
done();
});
}
};
};

storage.saveRegistry(sampleRegistry);
Expand All @@ -191,42 +184,40 @@ describe("S3 Storage", function () {

var requestNumber = 1;

AWS.S3 = {
Client: function (options) {
this.putObject = function (params, callback) {
if (requestNumber === 1) {
requestNumber++;
expect(params).toEqual({
Bucket: "repository.brackets.io",
Key: "registry.json",
ACL: "public-read",
ContentEncoding: "gzip",
ContentType: "application/json",
Body: jasmine.any(Buffer)
});
AWS.S3 = function (options) {
this.putObject = function (params, callback) {
if (requestNumber === 1) {
requestNumber++;
expect(params).toEqual({
Bucket: "repository.brackets.io",
Key: "registry.json",
ACL: "public-read",
ContentEncoding: "gzip",
ContentType: "application/json",
Body: jasmine.any(Buffer)
});

callback(null, {});
} else {
expect(params.Key.indexOf("registry_backups/registry")).toBe(0);
expect(params).toEqual({
Key: params.Key,
Bucket: "repository.brackets.io",
ACL: "public-read",
ContentEncoding: "gzip",
ContentType: "application/json",
Body: jasmine.any(Buffer)
});
callback(null, {});
} else {
expect(params.Key.indexOf("registry_backups/registry")).toBe(0);
expect(params).toEqual({
Key: params.Key,
Bucket: "repository.brackets.io",
ACL: "public-read",
ContentEncoding: "gzip",
ContentType: "application/json",
Body: jasmine.any(Buffer)
});

callback(null, {});
callback(null, {});

zlib.gunzip(params.Body, function (err, uncompressed) {
var registry = JSON.parse(uncompressed.toString());
expect(registry).toEqual(sampleRegistry);
done();
});
}
};
}
zlib.gunzip(params.Body, function (err, uncompressed) {
var registry = JSON.parse(uncompressed.toString());
expect(registry).toEqual(sampleRegistry);
done();
});
}
};
};

storage.saveRegistry(sampleRegistry);
Expand All @@ -237,36 +228,34 @@ describe("S3 Storage", function () {

var requestNumber = 1;

AWS.S3 = {
Client: function (options) {
this.putObject = function (params, callback) {
if (requestNumber === 1) {
requestNumber++;
expect(params).toEqual({
Bucket: "repository.brackets.io",
Key: "registry.json",
ACL: "public-read",
ContentEncoding: "gzip",
ContentType: "application/json",
Body: jasmine.any(Buffer)
});
AWS.S3 = function (options) {
this.putObject = function (params, callback) {
if (requestNumber === 1) {
requestNumber++;
expect(params).toEqual({
Bucket: "repository.brackets.io",
Key: "registry.json",
ACL: "public-read",
ContentEncoding: "gzip",
ContentType: "application/json",
Body: jasmine.any(Buffer)
});

callback(null, {});
} else {
expect(params.Key.startsWith("registry_backups/registry")).not.toBe(-1);
expect(params).toEqual({
Bucket: "repository.brackets.io",
ACL: "public-read",
ContentEncoding: "gzip",
ContentType: "application/json",
Body: jasmine.any(Buffer)
});
callback(null, {});
} else {
expect(params.Key.startsWith("registry_backups/registry")).not.toBe(-1);
expect(params).toEqual({
Bucket: "repository.brackets.io",
ACL: "public-read",
ContentEncoding: "gzip",
ContentType: "application/json",
Body: jasmine.any(Buffer)
});

callback("Couldn't access S3", {});
done();
}
};
}
callback("Couldn't access S3", {});
done();
}
};
};

storage.saveRegistry(sampleRegistry);
Expand Down Expand Up @@ -302,10 +291,8 @@ describe("S3 Storage", function () {
}
};

AWS.S3 = {
Client: function (options) {
this.putObject = putObject;
}
AWS.S3 = function (options) {
this.putObject = putObject;
};

storage.saveRegistry(sampleRegistry);
Expand All @@ -314,19 +301,17 @@ describe("S3 Storage", function () {
it("should save packages to S3", function (done) {
var storage = new s3storage.Storage(config);

AWS.S3 = {
Client: function (options) {
this.putObject = function (params, callback) {
expect(params).toEqual({
Bucket: "repository.brackets.io",
Key: "basic-valid-extension/basic-valid-extension-1.0.0.zip",
ACL: "public-read",
ContentType: "application/zip",
Body: jasmine.any(stream.Stream)
});
callback(null);
};
}
AWS.S3 = function (options) {
this.putObject = function (params, callback) {
expect(params).toEqual({
Bucket: "repository.brackets.io",
Key: "basic-valid-extension/basic-valid-extension-1.0.0.zip",
ACL: "public-read",
ContentType: "application/zip",
Body: jasmine.any(stream.Stream)
});
callback(null);
};
};

storage.savePackage({
Expand Down

0 comments on commit 5906d0f

Please sign in to comment.