Skip to content

Added support for [email protected] for tests #128

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

Merged
merged 7 commits into from
Jul 21, 2021
Merged
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
17 changes: 9 additions & 8 deletions .github/workflows/mocha-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@ on: [push, pull_request]
jobs:
build:
runs-on: ${{ matrix.os }}

strategy:
matrix:
os:
- ubuntu-latest
node:
- 14
- 8.17.0
splunk-version:
- "8.0"
- "latest"
- "latest"

services:
splunk:
image: splunk/splunk:${{matrix.splunk-version}}
Expand All @@ -28,15 +29,15 @@ jobs:
- 8000:8000
- 8088:8088
- 8089:8089

steps:
- uses: actions/checkout@v2

- name: Use node ${{ matrix.node }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}

- name: Create .splunkrc file
run: |
cd ~
Expand All @@ -46,10 +47,10 @@ jobs:
echo password=changed! >> .splunkrc
echo scheme=https >> .splunkrc
echo version=${{ matrix.splunk }} >> .splunkrc

- name: Run npm install
run: npm install

- name: Run server tests
run: make test
env:
Expand Down
2 changes: 1 addition & 1 deletion bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@
.concat(cmdline.opts.version ? makeOption("version", cmdline.opts.version) : "")
.concat(cmdline.opts.password ? makeOption("password", cmdline.opts.password) : "")
.concat(cmdline.opts.reporter ? makeOption("reporter", cmdline.opts.reporter.toLowerCase()) : "")
.concat(cmdline.opts.ui ? makeOption("ui", cmdline.opts.ui) : ["--ui", "exports"])
.concat(cmdline.opts.ui ? makeOption("ui", cmdline.opts.ui) : ["--ui", "bdd"])
.concat(cmdline.opts.timeout ? makeOption("timeout", cmdline.opts.timeout) : ["--timeout", "5000"])
.concat(cmdline.opts.grep ? makeOption("grep", cmdline.opts.grep) : "")
.concat(cmdline.opts.exit ? "--exit" : "--exit")
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"javascript"
],
"scripts": {
"test": "nyc mocha tests/tests.js --ui exports -t 50000 --exit"
"test": "mocha tests_spike/tests.js -t 50000 --allow-uncaught --exit"
},
"dependencies": {
"cookie": "0.4.1",
Expand All @@ -33,7 +33,7 @@
"browserify": "^17.0.0",
"chai": "^4.3.4",
"jshint": "2.13.0",
"mocha": "^9.0.2",
"mocha": "7.2.0",
"mustache": "4.2.0",
"nyc": "^15.1.0",
"readable-stream": "3.6.0",
Expand All @@ -48,4 +48,4 @@
"engine": {
"node": ">=0.8.0"
}
}
}
14 changes: 7 additions & 7 deletions tests/modularinputs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ var splunkjs = require('../../index');
splunkjs.Logger.setLevel("ALL");

// // Modular input tests
module.exports = {
'Event': require('./test_event').setup(),
'InputDefinition': require('./test_input_definition').setup(),
'ModularInput': require('./test_modularinput').setup(),
'Scheme': require('./test_scheme').setup(),
'ValidationDefinition': require('./test_validation_definition').setup(),
}
module.exports = (
require('./test_event').setup(),
require('./test_input_definition').setup(),
require('./test_modularinput').setup(),
require('./test_scheme').setup(),
require('./test_validation_definition').setup()
)

56 changes: 28 additions & 28 deletions tests/modularinputs/test_event.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ exports.setup = function () {
}
}

return {
"Event tests": {
beforeEach: function (done) {
return (
describe("Event tests", function () {
this.beforeEach(function (done) {
done();
},
});

"Event class handles times correctly - Date object": function (done) {
it("Event class handles times correctly - Date object", function (done) {
var now = Date.now();
var expected = (now / 1000).toFixed(3);
var found = Event.formatTime(now);
Expand All @@ -80,9 +80,9 @@ exports.setup = function () {
assert.equal(otherFound, otherExpected);

done();
},
});

"Event class handles times correctly - String": function (done) {
it("Event class handles times correctly - String", function (done) {
// Test time in seconds
var stringTime = "1372187084";
var expected = 1372187084.000;
Expand Down Expand Up @@ -114,9 +114,9 @@ exports.setup = function () {
assert.equal(found, expected);

done();
},
});

"Event class handles times correctly - Number (integer)": function (done) {
it("Event class handles times correctly - Number (integer)", function (done) {
// Test time in seconds
var intTime = 1372187084;
var expected = 1372187084.000;
Expand All @@ -142,9 +142,9 @@ exports.setup = function () {
assert.equal(found, expected);

done();
},
});

"Event class handles times correctly - Number (float)": function (done) {
it("Event class handles times correctly - Number (float)", function (done) {
// Test a perfect value
var floatTime = 1372187084.424;
var expected = 1372187084.424;
Expand Down Expand Up @@ -182,9 +182,9 @@ exports.setup = function () {
assert.equal(found, expected);

done();
},
});

"Event without enough fields throws error": function (done) {
it("Event without enough fields throws error", function (done) {
try {
var myEvent = new Event();
myEvent._writeTo(testUtils.getDuplexStream());
Expand All @@ -195,9 +195,9 @@ exports.setup = function () {
assert.ok(e);
}
done();
},
});

"Event with minimal config matches expected XML": function (done) {
it("Event with minimal config matches expected XML", function (done) {
var out = testUtils.getDuplexStream();

var myEvent = new Event({
Expand All @@ -219,9 +219,9 @@ exports.setup = function () {
assert.ok(false);
}
done();
},
});

"Event with full config matches expected XML": function (done) {
it("Event with full config matches expected XML", function (done) {
var out = testUtils.getDuplexStream();

var myEvent = new Event({
Expand Down Expand Up @@ -249,9 +249,9 @@ exports.setup = function () {
assert.ok(false);
}
done();
},
});

"EventWriter event writing works": function (done) {
it("EventWriter event writing works", function (done) {
var out = testUtils.getDuplexStream();
var err = testUtils.getDuplexStream();

Expand Down Expand Up @@ -291,9 +291,9 @@ exports.setup = function () {
assert.ok(false);
}
done();
},
});

"EventWriter gets an error from invalid Event": function (done) {
it("EventWriter gets an error from invalid Event", function (done) {
var out = testUtils.getDuplexStream();
var err = testUtils.getDuplexStream();

Expand All @@ -308,9 +308,9 @@ exports.setup = function () {
assert.ok(utils.startsWith(ew._err._read(), Logger.WARN));
}
done();
},
});

"EventWriter logging works": function (done) {
it("EventWriter logging works", function (done) {
var out = testUtils.getDuplexStream();
var err = testUtils.getDuplexStream();

Expand All @@ -324,9 +324,9 @@ exports.setup = function () {
assert.ok(false);
}
done();
},
});

"EventWriter XML writing works": function (done) {
it("EventWriter XML writing works", function (done) {
var out = testUtils.getDuplexStream();
var err = testUtils.getDuplexStream();

Expand All @@ -344,9 +344,9 @@ exports.setup = function () {
assert.ok(false);
}
done();
}
}
};
});
})
)
};

// Run the individual test suite
Expand Down
27 changes: 13 additions & 14 deletions tests/modularinputs/test_input_definition.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ exports.setup = function () {

splunkjs.Logger.setLevel("ALL");

return {
"Input Definition tests": {
beforeEach: function (done) {
return (
describe("Input Definition tests", function (done) {
this.beforeEach(function (done) {
done();
},
});

"Parse produces expected result - no inputs": function (done) {
it("Parse produces expected result - no inputs", function (done) {
var expected = new InputDefinition();
expected.metadata = {
"server_host": "tiny",
Expand All @@ -54,9 +54,9 @@ exports.setup = function () {
assert.ok(false);
}
done();
},
});

"Parse produces expected result - 2 inputs": function (done) {
it("Parse produces expected result - 2 inputs", function (done) {
var expected = new InputDefinition();
expected.metadata = {
"server_host": "tiny",
Expand Down Expand Up @@ -111,9 +111,9 @@ exports.setup = function () {
assert.ok(false);
}
done();
},
});

"Parse throws an error with malformed input definition": function (done) {
it("Parse throws an error with malformed input definition", function (done) {
try {
InputDefinition.parse(utils.readFile(__filename, "../data/conf_with_invalid_inputs.xml"));
assert.ok(false);
Expand All @@ -122,11 +122,10 @@ exports.setup = function () {
assert.ok(true);
}
done();
}
}
};
};

});
})
)
}
// Run the individual test suite
if (module === require.cache[__filename] && !module.parent) {
module.exports = exports.setup();
Expand Down
Loading