不要怂,就是干,撸起袖子干!

Commit 5cdd3bf7 by Sushant Committed by GitHub

build: mssql local tests setup (#10490)

1 parent ef40634f
...@@ -57,7 +57,7 @@ For MySQL this would look like this: ...@@ -57,7 +57,7 @@ For MySQL this would look like this:
$ echo "CREATE DATABASE sequelize_test;" | mysql -uroot $ echo "CREATE DATABASE sequelize_test;" | mysql -uroot
``` ```
**CLEVER NOTE:** by default, your local MySQL install must be with username `root` without password. If you want to customize that, you can set the environment variables `SEQ_DB`, `SEQ_USER`, `SEQ_PW`, `SEQ_HOST` and `SEQ_PORT`. **HINT:** by default, your local MySQL install must be with username `root` without password. If you want to customize that, you can set the environment variables `SEQ_DB`, `SEQ_USER`, `SEQ_PW`, `SEQ_HOST` and `SEQ_PORT`.
For Postgres, creating the database and (optionally) adding the test user this would look like: For Postgres, creating the database and (optionally) adding the test user this would look like:
...@@ -89,10 +89,12 @@ If running on macOS, install [Docker for Mac](https://docs.docker.com/docker-for ...@@ -89,10 +89,12 @@ If running on macOS, install [Docker for Mac](https://docs.docker.com/docker-for
Now launch the docker mysql and postgres servers with this command (you can add `-d` to run them in daemon mode): Now launch the docker mysql and postgres servers with this command (you can add `-d` to run them in daemon mode):
```sh ```sh
$ docker-compose up postgres-95 mysql-57 $ docker-compose up postgres-95 mysql-57 mssql
``` ```
Sequelize uses [special](https://github.com/sushantdhiman/sequelize-postgres) Docker image for PostgreSQL, which install all the extensions required by tests. **MSSQL:** Please run `npm run setup-mssql` to create the test database.
**POSTGRES:** Sequelize uses [special](https://github.com/sushantdhiman/sequelize-postgres) Docker image for PostgreSQL, which install all the extensions required by tests.
### 4. Running tests ### 4. Running tests
......
...@@ -156,6 +156,7 @@ ...@@ -156,6 +156,7 @@
"sscce-mysql": "cross-env DIALECT=mysql npm run sscce", "sscce-mysql": "cross-env DIALECT=mysql npm run sscce",
"sscce-postgres": "cross-env DIALECT=postgres npm run sscce", "sscce-postgres": "cross-env DIALECT=postgres npm run sscce",
"sscce-sqlite": "cross-env DIALECT=sqlite npm run sscce", "sscce-sqlite": "cross-env DIALECT=sqlite npm run sscce",
"sscce-mssql": "cross-env DIALECT=mssql npm run sscce" "sscce-mssql": "cross-env DIALECT=mssql npm run sscce",
"setup-mssql": "env-cmd $npm_package_options_env_cmd ./scripts/setup-mssql"
} }
} }
docker exec mssql /bin/bash -c '/opt/mssql-tools/bin/sqlcmd -S 127.0.0.1 -U "sa" -d "master" -P '"'$SEQ_MSSQL_PW'"' -Q "DROP DATABASE ['$SEQ_MSSQL_DB']; CREATE DATABASE ['$SEQ_MSSQL_DB']; ALTER DATABASE ['$SEQ_MSSQL_DB'] SET READ_COMMITTED_SNAPSHOT ON;"'
\ No newline at end of file
...@@ -9,6 +9,6 @@ SEQ_PG_PORT=8990 ...@@ -9,6 +9,6 @@ SEQ_PG_PORT=8990
SEQ_PG_USER=sequelize_test SEQ_PG_USER=sequelize_test
SEQ_PG_PW=sequelize_test SEQ_PG_PW=sequelize_test
SEQ_MSSQL_PORT=8970 SEQ_MSSQL_PORT=8970
SEQ_MSSQL_DB=master SEQ_MSSQL_DB=sequelize_test
SEQ_MSSQL_USER=sa SEQ_MSSQL_USER=sa
SEQ_MSSQL_PW=yourStrong(!)Password SEQ_MSSQL_PW=yourStrong(!)Password
...@@ -6,12 +6,10 @@ const fs = require('fs'), ...@@ -6,12 +6,10 @@ const fs = require('fs'),
Sequelize = require('../index'), Sequelize = require('../index'),
DataTypes = require('../lib/data-types'), DataTypes = require('../lib/data-types'),
Config = require('./config/config'), Config = require('./config/config'),
supportShim = require('./supportShim'),
chai = require('chai'), chai = require('chai'),
expect = chai.expect, expect = chai.expect,
AbstractQueryGenerator = require('../lib/dialects/abstract/query-generator'); AbstractQueryGenerator = require('../lib/dialects/abstract/query-generator');
chai.use(require('chai-spies')); chai.use(require('chai-spies'));
chai.use(require('chai-datetime')); chai.use(require('chai-datetime'));
chai.use(require('chai-as-promised')); chai.use(require('chai-as-promised'));
...@@ -30,10 +28,6 @@ Sequelize.Promise.onPossiblyUnhandledRejection(e => { ...@@ -30,10 +28,6 @@ Sequelize.Promise.onPossiblyUnhandledRejection(e => {
}); });
Sequelize.Promise.longStackTraces(); Sequelize.Promise.longStackTraces();
// shim all Sequelize methods for testing for correct `options.logging` passing
// and no modification of `options` objects
if (!process.env.COVERAGE && process.env.SHIM) supportShim(Sequelize);
const Support = { const Support = {
Sequelize, Sequelize,
...@@ -228,8 +222,7 @@ const Support = { ...@@ -228,8 +222,7 @@ const Support = {
credentials += `:${dbConfig.password}`; credentials += `:${dbConfig.password}`;
} }
url = `${config.dialect}://${credentials url = `${config.dialect}://${credentials}@${dbConfig.host}:${dbConfig.port}/${dbConfig.database}`;
}@${dbConfig.host}:${dbConfig.port}/${dbConfig.database}`;
} }
return url; return url;
}, },
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!