README
PLUM.MODELS
This repository contains the sequelize models and the plum.databases.documentdb.
NOTE: Database script development will continue within this repository under the databases/ folder. plum.databases.documentdb development will be redirected to this repository.
Requirements
- MSSQL
- node 8.10+
- jest
[Optional] MSSQL Setup
This is how the bitbucket-pipelines is setting up its MSSQL
docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=yourStrong(!)Password' -p 1433:1433 --name mssql -d microsoft/mssql-server-linux:latest
Development
Create a .env file
example content, configure depending on how you setup your MSSQL server
MSSQL_HOST=192.168.99.100
MSSQL_PASSWORD=yourStrong(!)Password
MSSQL_DATABASE=DocumentDb
MSSQL_USER=sa
Running Tests
The objective of running the tests is to make sure that the orm models
, model associations
and database scripts
are compatible.
# install all dependencies
npm i
# to test
npm test
# to test individual file/s
jest __test__/Filename1 __test__/Filename2
Expectations
What to test
Every change in the model requires an update in the tests under the __tests__/ folder.
- column/attribute changes
- please update the corresponding factory object under the __tests__/factories/ModelName.js
- data type testing are also important
- association changes
- requires updating the factory object also
- requires adding test under __tests__/ModelName.test.js to determine whether the association is included or populated correctly
- class and instance methods
Notes
- When making a PR make sure it passes all the tests first.
- Configure the model the be perfectly equal to the database script configuration
- ie: varchar limits, types, validation etc.
How Does this work
- when running
jest
ornpm test
- the setupTests.js determines whether to create the database or truncate the tables under the database
- creating the database requires executing the following scripts in sequence
- master-ddl.sql
- changeset.sql
- release-changeset.sql
- setupTests.js runs for every test suite or every test file