Skip to content

Commit 4c85ca0

Browse files
committed
Merge pull request #496 from kai-koch/master
* Adding support for unit tests on windows systems * Clarified the use of config option 'charset'
2 parents 4a5c000 + 463d9b3 commit 4c85ca0

File tree

3 files changed

+50
-3
lines changed

3 files changed

+50
-3
lines changed

Readme.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ When establishing a connection, you can set the following options:
138138
* `user`: The MySQL user to authenticate as.
139139
* `password`: The password of that MySQL user.
140140
* `database`: Name of the database to use for this connection (Optional).
141-
* `charset`: The charset for the connection. (Default: `'UTF8_GENERAL_CI'`)
141+
* `charset`: The charset for the connection. (Default: `'UTF8_GENERAL_CI'`. Value needs to be all in upper case letters!)
142142
* `timezone`: The timezone used to store local dates. (Default: `'local'`)
143143
* `stringifyObjects`: Stringify objects instead of converting to values. See
144144
issue [#501](https://github.com/felixge/node-mysql/issues/501). (Default: `'false'`)
@@ -880,6 +880,14 @@ For example, if you have an installation of mysql running on localhost:3306 and
880880
MYSQL_HOST=localhost MYSQL_PORT=3306 MYSQL_DATABASE=node_mysql_test MYSQL_USER=root MYSQL_PASSWORD= make test
881881
```
882882

883+
## Running unit tests on windows
884+
885+
* Edit the variables in the file ```make.bat``` according to your system and mysql-settings.
886+
* Make sure the database (e.g. 'test') you want to use exists and the user you entered has the proper rights to use the test database. (E.g. do not forget to execute the SQL-command ```FLUSH PRIVILEGES``` after you have created the user.)
887+
* In a DOS-box (or CMD-shell) in the folder of your application run ```npm install mysql --dev``` or in the mysql folder (```node_modules\mysql```), run ```npm install --dev```. (This will install additional developer-dependencies for node-mysql.)
888+
* Run ```npm test mysql``` in your applications folder or ```npm test``` in the mysql subfolder.
889+
* If you want to log the output into a file use ```npm test mysql > test.log``` or ```npm test > test.log```.
890+
883891
## Todo
884892

885893
* Prepared statements

make.bat

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
@ECHO OFF
2+
REM Simple 'make' replacement for windows-based system, 'npm test' will now find
3+
REM 'make.bat' and sets the MYSQL_ enviroment variables according to this file
4+
5+
REM Edit the variables according to your system
6+
REM No spaces (' ') between variablenames, '=' and the values!
7+
8+
REM Host to test with default: localhost
9+
SET MYSQL_HOST=localhost
10+
11+
REM Default mysql port: 3306
12+
SET MYSQL_PORT=3306
13+
14+
REM For a standard installatons of Wampp using http://www.apachefriends.org/
15+
REM the default login is 'root' and no password, but any user should do, change
16+
REM the settings according to your installation
17+
SET MYSQL_USER=root
18+
SET MYSQL_PASSWORD=
19+
20+
REM make sure the database you are using exists and the above user has access to
21+
REM it. Normally every user has access to the database 'test'
22+
SET MYSQL_DATABASE=test
23+
24+
@ECHO ON
25+
node test/run.js
26+
@ECHO OFF
27+
ECHO **********************
28+
ECHO If the tests should fail, make sure you have SET the correct values for the enviroment variables in the file 'make.bat'
29+
ECHO **********************

test/integration/connection/test-unix-domain-socket.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
1+
/**
2+
* This test is skipped, if the environment variable "windir" is set.
3+
* It assumes that it runs on a windows system then.
4+
*/
5+
if (process.env.windir) {
6+
return console.log('Skipping "test-unix-domain-socket.js" - Environment'
7+
+ ' variable "windir" is set. Skipping this, because we seem to be on'
8+
+ ' a windows system');
9+
}
110
var common = require('../../common');
211
var connection = common.createConnection({socketPath: common.fakeServerSocket});
312
var assert = require('assert');
413

514
var server = common.createFakeServer();
615
var didConnect = false;
16+
717
server.listen(common.fakeServerSocket, function(err) {
818
if (err) throw err;
919

@@ -27,6 +37,6 @@ server.on('connection', function(connection) {
2737
});
2838

2939
process.on('exit', function() {
30-
assert.equal(didConnect, true);
31-
assert.equal(hadConnection, true);
40+
assert.equal(didConnect, true);
41+
assert.equal(hadConnection, true);
3242
});

0 commit comments

Comments
 (0)