Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update gitignore for Node.js, Python, and Java projects #831

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 39 additions & 1 deletion core/jazz_logs/config/test-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,43 @@
"VALID_ENVIRONMENTS" : ["prod", "stg", "dev", "test"],
"VALID_CATEGORIES" : ["api", "function"],
"VALID_LOGTYPES" : ["warn", "error", "info", "verbose", "debug"],
"ENV_PREFIX" : "bA11r00m-dAnCe"
"ENV_PREFIX" : "bA11r00m-dAnCe",
"LOG_LEVELS": [
{
"Level": 0,
"Type": "off"
},
{
"Level": 1,
"Type": "fatal"
},
{
"Level": 2,
"Type": "error"
},
{
"Level": 3,
"Type": "warn"
},
{
"Level": 4,
"Type": "info"
},
{
"Level": 5,
"Type": "debug"
},
{
"Level": 6,
"Type": "trace"
},
{
"Level": 7,
"Type": "verbose"
},
{
"Level": 8,
"Type": "all"
}
]
}
2 changes: 1 addition & 1 deletion core/jazz_logs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ module.exports.handler = (event, context, cb) => {
req.url = config.BASE_URL + "/_plugin/kibana/elasticsearch/_msearch";
req.body = setRequestBody(servCategory, env, querys, startTime, endTime, size, page);

request(req, function (err, res, body) {
request.post(req, function (err, res, body) {
if (err) {
logger.error("Error occured : " + JSON.stringify(err));
return cb(JSON.stringify(errorHandler.throwInternalServerError("Internal Error")));
Expand Down
2 changes: 1 addition & 1 deletion core/jazz_logs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
"chai": "^3.5.0",
"lambda-local": "^1.4.2",
"mocha": "^v3.0.0",
"sinon": "^1.17.7"
"sinon": "^7.2.3"
}
}
44 changes: 20 additions & 24 deletions core/jazz_logs/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const awsContext = require('aws-lambda-mock-context');
const sinon = require('sinon');
const logger = require("../components/logger.js");
const request = require('request');
const _ = require('lodash');

describe('platform_logs', function() {
var event, context, callback, spy, stub, logStub, logMessage, errorMessage, errorType;
Expand Down Expand Up @@ -252,23 +253,20 @@ describe('platform_logs', function() {
* Given valid input parameters, handler() should attempt to send an http request
* @param {object, object, function} default event, context, and callback as described in beforeEach
*/
/* Disabling failing test
it("should attempt to make an http request if given valid inputs", function(){
//wrapping the Request() method that gets internally called by node request.js for any http method
stub = sinon.stub(request, "Request", spy);
stub = sinon.stub(request, "post").callsFake(spy);
//trigger the spy wrapping the request by calling handler() with valid params
var callFunction = index.handler(event, context, callback);
assert.isTrue(spy.calledOnce);
stub.restore();
assert.isTrue(spy.called);
});
*/

/*
* Given a failed http request, handler() informs that there was a request error
* @param {object, object, function} default event, context, and callback as described in beforeEach
* @returns {string} returns callback() with an error obj passed so the error is relayed as a message
*/
/* Disabling failing test
it("should catch an error from sending request", function(){
var err = {
errType : "otherTanzen",
Expand All @@ -279,28 +277,27 @@ describe('platform_logs', function() {
logMessage = "Error occured : ";
//wrapping the Request() method that gets internally called by node request.js for any request
//the expected parameter only includes a requestLoad obj that has a callback function property
stub = sinon.stub(request, "Request", (obj) => {
return obj.callback(err, null, null);
stub = sinon.stub(request, "post").callsFake((options, cb) => {
return cb(err, null, null);
});
logStub = sinon.stub(logger, "error", spy);
logStub = sinon.stub(logger, "error").callsFake(spy);
//trigger both stubs by calling handler()
var callFunction = index.handler(event, context, callback);
var allChecks = stub.returnValues[0].includes(errorType) &&
stub.returnValues[0].includes(errorMessage) &&
logStub.args[0][0].includes(err.errType) &&
logStub.args[0][0].includes(err.message) &&
logStub.args[0][0].includes(logMessage);
var allChecks = _.includes(stub.returnValues[0], errorType) &&
_.includes(stub.returnValues[0], errorMessage) &&
_.includes(logStub.args[0][0], err.errType) &&
_.includes(logStub.args[0][0], err.message) &&
_.includes(logStub.args[0][0], logMessage);

stub.restore();
logStub.restore();
assert.isTrue(allChecks);
});
*/

/*
* Given a 200 response, handler() reveals content of returned response
* @param {object, object, function} default event, context, and callback as described in beforeEach
*/
/* Disabling failing test
it("should get output back from a successful 200 response", function(){
var responseObject = {
statusCode : 200,
Expand All @@ -321,24 +318,23 @@ describe('platform_logs', function() {
responseObject.body = JSON.stringify(responseObject.body);
logMessage = "Output :";
//wrapping the Request() method that gets internally called by node request.js for any request
stub = sinon.stub(request, "Request", (obj) => {
return obj.callback(null, responseObject, null);
stub = sinon.stub(request, "post").callsFake((options, cb) => {
return cb(null, responseObject, null);
});
logStub = sinon.stub(logger, "info", spy);
logStub = sinon.stub(logger, "info").callsFake(spy);
//trigger both stubs by calling handler()
var callFunction = index.handler(event, context, callback);
var bool = logStub.args[3][0].includes(logMessage);
stub.restore();
logStub.restore();
assert.isTrue(bool);
}); */
});

/*
* Given an unsuccessful response, handler() informs of error
* @param {object, object, function} default event, context, and callback as described in beforeEach
* @returns {string} returns callback() with an error obj passed so the error is relayed as a message
*/
/* Disabling failing test
it("should notify of internal server error if request returns an unsuccesful response", () => {
errorType = "InternalServerError";
errorMessage = "Error while processing the request :";
Expand All @@ -357,10 +353,10 @@ describe('platform_logs', function() {
responseObject.body = JSON.stringify(responseObject.body);
//wrapping the Request() method that gets internally called by node request.js for any request
//the expected parameter only includes a requestLoad obj that has a callback function property
stub = sinon.stub(request, "Request", (obj) => {
return obj.callback(null, responseObject, null);
stub = sinon.stub(request, "post").callsFake((options, cb) => {
return cb(null, responseObject, null);
});
logStub = sinon.stub(logger, "error", spy);
logStub = sinon.stub(logger, "error").callsFake(spy);
//trigger both stubs by calling handler()
var callFunction = index.handler(event, context, callback);
var allChecks = stub.returnValues[0].includes(errorType) &&
Expand All @@ -370,5 +366,5 @@ describe('platform_logs', function() {
stub.restore();
logStub.restore();
assert.isTrue(allChecks);
});*/
});
});