Skip to content
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

added mssql for docker tests #48

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: node_js
node_js:
- stable
- "10"
env:
- TRAVIS=true
services:
Expand Down
8 changes: 8 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ services:
- "1521:1521"
mysql:
image: mysql
command: mysqld --default-authentication-plugin=mysql_native_password
ports:
- "3306:3306"
environment:
Expand All @@ -17,3 +18,10 @@ services:
- "5432:5432"
environment:
- POSTGRES_PASSWORD=password
mssql:
image: microsoft/mssql-server-linux
ports:
- "1433:1433"
environment:
- ACCEPT_EULA=Y
- SA_PASSWORD=PassWord123
26 changes: 20 additions & 6 deletions test/mssqlSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@ var sworm = require('..')
var expect = require('chai').expect

var database = {
createDatabase: function() {
var db = sworm.db(config());
return db.query(
"If(db_id(N'sworm') IS NULL)\n" +
"begin\n" +
"create database sworm\n" +
"end"
);
},

createTables: function(db, tables) {
function createTable(name, sql) {
tables.push(name);
Expand Down Expand Up @@ -63,16 +73,20 @@ var database = {
driverModuleName: "mssql"
};

var config = {
driver: "mssql",
config: { user: "user", password: "password", server: "windows", database: "sworm" }
function config (database) {
return {
driver: "mssql",
config: { user: "sa", password: "PassWord123", server: "localhost", database: database }
}
}

var swormConfig = config('sworm')

if (!process.env.TRAVIS) {
describeDatabase("mssql", config, database, function () {
describeDatabase("mssql", swormConfig, database, function () {
describe('generatedId', function () {
it('can insert row with uniqueidentifier and get id correctly', function () {
var db = sworm.db(config)
var db = sworm.db(swormConfig)
var person = db.model({table: 'people_uuid', generatedId: 'output'});

var bob = person({name: 'bob'})
Expand All @@ -84,7 +98,7 @@ if (!process.env.TRAVIS) {
})

it('can insert empty row with uniqueidentifier and get id correctly', function () {
var db = sworm.db(config)
var db = sworm.db(swormConfig)
var person = db.model({table: 'people_uuid', generatedId: 'output'});

var bob = person({})
Expand Down