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

Commit

Permalink
Merge pull request #20 from snyk/amir/print_transmission_url
Browse files Browse the repository at this point in the history
feat: printing transmission url
  • Loading branch information
Shesekino authored Oct 21, 2018
2 parents 7938c0a + ca66215 commit 5b82f4d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
}
],
"max-depth": [1, 3],
"max-len": [1, 80],
"max-len": [1, 120],
"max-statements": [1, 25],
"new-cap": 0,
"no-caller": 2,
Expand Down
2 changes: 1 addition & 1 deletion lib/transmitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function start({
function transmitEvents(url, projectId) {
let postPromise = Promise.resolve();
if (eventsToSend.length) {
debug(`Transmitting ${eventsToSend.length} events.`);
debug(`Transmitting ${eventsToSend.length} events to ${url} with project ID ${projectId}.`);
postPromise = needle('post', url, {projectId, eventsToSend}, {json: true})
.then((response) => {
if (response && response.statusCode !== 200) {
Expand Down
16 changes: 8 additions & 8 deletions test/transmitter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ test('Transmitter prints nothing for no events', async function (t) {
t.equal(spy.getCalls().length, 0, 'no debug messages for no events');
});

test('Transmitter transmits nothingfor no events', async function (t) {
test('Transmitter transmits nothing for no events', async function (t) {
nock('http://host')
.post('/method')
.reply(200, {});

await transmitter.transmitEvents('http://host/method', 'projectId');
await transmitter.transmitEvents('http://host/method', 'some-project-id');
t.ok(!nock.isDone(), 'no transmission sent');
nock.cleanAll();
});
Expand All @@ -31,10 +31,10 @@ test('Trasmitter prints success on transmitted events', async function(t) {
transmitter.addEvent({foo: 'bar'});
spy.resetHistory();

await transmitter.transmitEvents('http://host/method', 'projectId')
await transmitter.transmitEvents('http://host/method', 'some-project-id')
.then(() => {
const calls = spy.getCalls();
t.equal(calls[0].args[0], 'Transmitting 1 events.', 'printing count of transmitted events');
t.equal(calls[0].args[0], 'Transmitting 1 events to http://host/method with project ID some-project-id.', 'printing count of transmitted events');
t.equal(calls[1].args[0], 'Successfully transmitted events.', 'printing count of transmitted events');
t.end();
nock.cleanAll();
Expand All @@ -49,10 +49,10 @@ test('Transmitter prints errors on non-OK http responses', async function(t) {
transmitter.addEvent({foo: 'bar'});
spy.resetHistory();

await transmitter.transmitEvents('http://host/method', 'projectId')
await transmitter.transmitEvents('http://host/method', 'some-project-id')
.then(() => {
const calls = spy.getCalls();
t.equal(calls[0].args[0], 'Transmitting 1 events.', 'printing count of transmitted events');
t.equal(calls[0].args[0], 'Transmitting 1 events to http://host/method with project ID some-project-id.', 'printing count of transmitted events');
t.equal(calls[1].args[0], 'Unexpected response for events transmission: 404 : {"type":"Buffer","data":[]}', 'printing unexpected http responses');
t.end();
nock.cleanAll();
Expand All @@ -67,10 +67,10 @@ test('Transmitter prints errors on errors', async function(t) {
transmitter.addEvent({foo: 'bar'});
spy.resetHistory();

await transmitter.transmitEvents('http://host/method', 'projectId')
await transmitter.transmitEvents('http://host/method', 'some-project-id')
.then(() => {
const calls = spy.getCalls();
t.equal(calls[0].args[0], 'Transmitting 1 events.', 'printing count of transmitted events');
t.equal(calls[0].args[0], 'Transmitting 1 events to http://host/method with project ID some-project-id.', 'printing count of transmitted events');
t.equal(calls[1].args[0], 'Error transmitting events: Error: network is down!', 'printing errors from needle');
t.end();
nock.cleanAll();
Expand Down

0 comments on commit 5b82f4d

Please sign in to comment.