Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Greetings!
I have been working on adding tests to mock-knex for mssql, since I have been using this a lot in a project of mine, and its so useful :). I wanted to initially add a single test (due to #91) however I noticed that there weren't any mssql tests in here. This is my attempt at getting the base test-suite to work with mssql.
I had to make a few modifications to get the
make test-suite
command to work with the new mssql directory. I'll attempt to describe the modifications here.docker-compose.yml:
Modified to setup a MSSQL database (running on a different port than usual, due to port conflict with one of the other dbs)
package.json:
Added the node mssql official module
test directory:
I copied over one of the existing folders (mysql), renamed it to be "mssql" and then made some modifications within there. I had some trouble getting this test working in particular, titled "should support schema#hasTable". I was a bit fuzzy on the differences between
information_schema.tables
andsys.tables
so I added what the mssql implementation was setting the query to be in the expect array. This maybe incorrect, so please let me know if I'm doing something wrong here.platform directory:
After adding the mssql tests, for some reason, the Transaction tests required the mock connection to have new transaction functions (begin, rollback and commit). So I have added them to get rid of the errors I was seeing. This might be a misunderstanding on my part on how this is working, so I welcome feedback.
test/run.js:
I had to modify this because some of the older versions of knex didn't even have the dialects/mssql folder at all. I believe that knex didn't add support for mssql until version 0.11, so I needed to selectively only run the mssql tests when a valid version of knex was installed. In particular, version 0.15 also had issues with the version of the mssql module I am using.
Please feel free to provide any feedback, I would be happy to make any changes to this. Also, if it isn't helpful at all, thats ok too,
Thank you!