Skip to content

Commit 38ee51f

Browse files
committed
Added integration tests.
1 parent 997ce29 commit 38ee51f

File tree

4 files changed

+87
-2
lines changed

4 files changed

+87
-2
lines changed

Makefile

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# TESTS
2+
3+
TESTER = ./node_modules/.bin/mocha
4+
OPTS = --growl --ignore-leaks --timeout 30000
5+
TESTS = test/*.test.js
6+
INTEGRATION = test/*.integration.js
7+
JSHINT = ./node_modules/.bin/jshint
8+
9+
JS_FILES = $(shell find . -type f -name "*.js" \
10+
-not -path "./node_modules/*" -and \
11+
-not -path "./broker/*" -and \
12+
-not -path "./coverage/*" -and \
13+
-not -path "./dev/*" -and \
14+
-not -path "./vendor/*" -and \
15+
-not -path "./broker/*" -and \
16+
-not -path "./public/_js/*" -and \
17+
-not -path "./config/database.js" -and \
18+
-not -path "./public/js/*.js" -and \
19+
-not -path "./newrelic.js" -and \
20+
-not -path "./db/schema.js")
21+
22+
check:
23+
@$(JSHINT) $(JS_FILES) && echo 'Those who know do not speak. Those who speak do not know.'
24+
25+
test:
26+
$(TESTER) $(OPTS) $(TESTS)
27+
test-verbose:
28+
$(TESTER) $(OPTS) --reporter spec $(TESTS)
29+
test-integration:
30+
$(TESTER) $(OPTS) --reporter spec $(INTEGRATION)
31+
test-full:
32+
$(TESTER) $(OPTS) --reporter spec $(TESTS) $(INTEGRATION)
33+
testing:
34+
$(TESTER) $(OPTS) --watch $(TESTS)
35+
features:
36+
NODE_ENV=test node_modules/.bin/cucumber.js
37+
38+
.PHONY: test doc docs features
39+

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ This is a node driver for SRCDS's RCON. While it should work on all SRCDS versio
1818

1919
The current version `2.x` requires node.js version 4.x or newer. For older node.js versions including 0.8, install srcds-rcon `1.1.7`. All development uses node.js 5.x.
2020

21+
## Testing
22+
23+
Install dev dependencies (`npm install` does that by default). Set up a csgo server and bind it to `127.0.0.1:27015`, run it with `-usercon` and `rcon_password test`. Then run `make test`.
24+
25+
Alternatively, set up a different server and edit `test/integration.test.js` `getIntegrationAuth` to return login details to the desired test server.
26+
2127
## Usage
2228

2329
#### First establish connection

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "srcds-rcon",
3-
"version": "2.1.0",
3+
"version": "2.1.1",
44
"description": "A node.js driver for the SRCDS RCON",
55
"main": "index.js",
66
"scripts": {
@@ -26,6 +26,10 @@
2626
"bugs": {
2727
"url": "https://github.com/randunel/node-srcds-rcon/issues"
2828
},
29-
"homepage": "https://github.com/randunel/node-srcds-rcon#readme"
29+
"homepage": "https://github.com/randunel/node-srcds-rcon#readme",
30+
"devDependencies": {
31+
"should": "~7.1.1",
32+
"mocha": "~2.3.4"
33+
}
3034
}
3135

test/integration.test.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
'use strict';
2+
3+
let rcon = require('../');
4+
let should = require('should');
5+
6+
describe('integration', () => {
7+
it('should connect to server', () => rcon(getIntegrationAuth()).connect().catch(
8+
err => should.not.exist(err)
9+
));
10+
11+
it('should run single packet command', () => {
12+
let server = rcon(getIntegrationAuth());
13+
return server.connect().then(
14+
() => server.command('status')
15+
).then(
16+
status => status.should.containEql('hostname')
17+
);
18+
});
19+
20+
it('should work with multi packet commands', () => {
21+
let server = rcon(getIntegrationAuth());
22+
return server.connect().then(
23+
() => server.command('cvarlist')
24+
).then(
25+
cvarlist => cvarlist.should.containEql('concommands')
26+
);
27+
});
28+
});
29+
30+
function getIntegrationAuth() {
31+
return {
32+
address: '127.0.0.1',
33+
password: 'test'
34+
};
35+
}
36+

0 commit comments

Comments
 (0)