Permalink
Browse files

Prep for writing unit tests

  • Loading branch information...
1 parent 6299df4 commit c8c4a5414d93812dea348528d1acf253f1712757 @gonerandom committed Jul 23, 2013
Showing with 46 additions and 3 deletions.
  1. +7 −0 CreateLogTable.sql
  2. +13 −2 README.md
  3. +1 −1 lib/winston-sqlserver.js
  4. +25 −0 test/test-config.js
View
@@ -0,0 +1,7 @@
+CREATE TABLE [dbo].[NodeLogs] (
+ [Id] BIGINT IDENTITY (1, 1) NOT NULL,
+ [LogDate] DATETIME2 (3) NOT NULL,
+ [Level] NVARCHAR (5) NOT NULL,
+ [Message] NTEXT NOT NULL,
+ CONSTRAINT [PK_dbo.NodeLogs] PRIMARY KEY CLUSTERED ([Id] ASC)
+);
View
@@ -4,7 +4,11 @@ This module allows you to log your [winston](//github.com/flatiron/winston/) mes
## Installation
-Coming soon.
+1. Follow the steps in [How to Access Windows Azure SQL Database from Node.js](http://www.windowsazure.com/en-us/develop/nodejs/how-to-guides/sql-database/) to get the [node-sqlserver](//github.com/WindowsAzure/node-sqlserver/) package installed.
+2. Use npm to install [winston](//github.com/flatiron/winston/) and this package.
+3. In the database you will use for logging, execute `CreateLogTable.sql` to create a table of the form necessary for this package.
+
+More coming soon.
## Usage
@@ -17,6 +21,13 @@ require('winston-sqlserver');
winston.add(winston.transports.SQLServer, options);
```
+## Testing
+
+Unit tests can be found in the `test` directory.
+They require [mocha](//github.com/visionmedia/mocha) and [should](//github.com/visionmedia/should.js) to be installed via npm.
+Testing can be configured with variables in test-config.js.
+The default settings assume SQL Express has been installed and `CreateLogTable.sql` has been run in a database called **winston**.
+
## Thanks
-Developed based on the [winston-sqlite](//github.com/floatingLomas/winston-sqlite/) and [winston-mail](//github.com/wavded/winston-mail/) projects.
+Developed based on the [winston-sqlite](//github.com/floatingLomas/winston-sqlite/), [winston-mail](//github.com/wavded/winston-mail/), [winston-skywriter](https://github.com/pofallon/winston-skywriter/) projects as references.
View
@@ -16,7 +16,7 @@ var sql = require('node-sqlserver');
winston.Transport.call(this, options);
this.name = 'sqlserver';
- this.connectionString = options.connectionString || 'Driver={SQL Server Native Client 11.0};Server=(local);Trusted_Connection={Yes};Database={winston}';
+ this.connectionString = options.connectionString || 'Driver={SQL Server Native Client 11.0};Server=(local);Trusted_Connection=Yes;Database=winston';
}
/**
View
@@ -0,0 +1,25 @@
+// Update the below values with your settings
+var driver = 'SQL Server Native Client 11.0';
+var server = '.\\SQLEXPRESS';
+var userId = '';
+var password = '';
+var database = 'winston';
+var trustedConnection = true;
+
+
+
+// Generate connection string and exports
+var connectionString =
+ "Driver={" + driver + "};" +
+ "Server=" + server + ";" +
+ "Database=" + database + ";" +
+ (useTrustedConnection === true ?
+ "Trusted_Connection=Yes;" :
+ "Uid=" + userId + ";Pwd=" + password + ";");
+exports.driver = driver;
+exports.server = server;
+exports.userId = userId;
+exports.password = password;
+exports.database = database;
+exports.trustedConnection = trustedConnection;
+exports.connectionString = connectionString;

0 comments on commit c8c4a54

Please sign in to comment.