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

Add unit tests for table comment #2098

Merged
merged 1 commit into from Jun 10, 2017
Merged

Conversation

izri16
Copy link
Contributor

@izri16 izri16 commented Jun 3, 2017

I created tests to add table comment. These are for postgresql, mysql and oracle as it seems to me that .comment() function is not supported for sqlite.
I test setting the comment and setting it back to empty string. I assume that many users will expect that .comment(null) or simply .comment() will work the same as .comment('') I also made tests for these cases. However .comment(null) and .comment() does not work that way in mysql so these tests are only for postgresql and oracle.

expect(tableSql[0].sql).to.equal('comment on table "users" is \'\'');
});

it('test set empty comment using null', function() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't consider setting comment to be empty string by setting it to null or undefined as a intended behaviour. So better to not add test for that functionality, since better test would be throwing an error because of invalid parameter.

Copy link
Member

@elhigu elhigu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for tests! They look fine, except that none of the dialects should have tests that .comment with undefined / null / falsy param sets empty string comment. Invalid parameters should throw an error (any parameter that is not string).

So please delete those tests setting comments with non-string arguments and I can merge this.

@izri16
Copy link
Contributor Author

izri16 commented Jun 10, 2017

Ok I deleted those non-string args tests and rebased.

* Tests for setting comment on table for postgresql, mysql and oracle

* No tests for sqlite as it does not seem to support comments

* No tests for mssql as it can not be tested simply using sql comparison
@elhigu elhigu merged commit e63fe22 into knex:master Jun 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants