Skip to content

fix: type createTableQuery and overhaul unit test suite - #15526

Merged
WikiRik merged 16 commits into
mainfrom
WikiRik/create-table-query-unit-tests
Mar 24, 2023
Merged

WikiRik merged 16 commits into
mainfrom
WikiRik/create-table-query-unit-tests

Conversation

@WikiRik

@WikiRik WikiRik commented Jan 4, 2023

Copy link
Copy Markdown
Member

Pull Request Checklist

  • Have you added new tests to prevent regressions?
  • If a documentation update is necessary, have you opened a PR to the documentation repository?
  • Did you update the typescript typings accordingly (if applicable)?
  • Does the description below contain a link to an existing issue (Closes #[issue]) or a description of the issue you are solving?
  • Does the name of your PR follow our conventions?

Description Of Change

This PR is smaller than the others; this time I just unified the tests, added missing expectations and quickly typed createTableQuery. Future PRs can migrate createTableQuery to TypeScript and clean up the test suite.

Todos

@WikiRik
WikiRik marked this pull request as ready for review January 4, 2023 18:17
@WikiRik
WikiRik marked this pull request as draft January 4, 2023 18:18
@WikiRik
WikiRik marked this pull request as ready for review January 4, 2023 19:50

@evanrittenhouse evanrittenhouse left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good for the most part, only blocker for me would be changing the test names

@WikiRik
WikiRik marked this pull request as draft March 12, 2023 10:48
@WikiRik
WikiRik marked this pull request as ready for review March 12, 2023 11:15

@ephys ephys left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A lot of these tests seems to be duplicates of each-other, or testing the same thing

It makes it look like we're thoroughly testing that API but in reality they're all the same test

I think it's better to remove the duplicates and add specific tests with explanations when we encounter specific issues

@WikiRik

WikiRik commented Mar 12, 2023

Copy link
Copy Markdown
Member Author

A lot of these tests seems to be duplicates of each-other, or testing the same thing

It makes it look like we're thoroughly testing that API but in reality they're all the same test

I think it's better to remove the duplicates and add specific tests with explanations when we encounter specific issues

You're absolutely correct. What I've done for this PR is just combining all test cases in this file and setting the expectations for all dialects. This test suite should be overhauled so all those duplicates are removed, as per my comment at the top of the file;

// TODO: overhaul this test suite when migrating createTableQuery to TypeScript
/**
* Make methods stricter, throw when using invalid options
* Accept and test for TableNameOrModel
* Check if createTableQuery is typed correctly
* Check if all tests make sense, the current tests are just copied from dialect specific tests and other expectations are added
* Give tests better names
* Make sure that all resulting queries are valid by adding integration tests for QueryInterface.createTable
*/

I was planning that it would be done in future PRs but if you want I could also work on it in this PR.

@ephys

ephys commented Mar 12, 2023

Copy link
Copy Markdown
Member

This is how I see view the different notes:


These change the behavior of the method and make sense to do in the TS PR:

  • Make methods stricter, throw when using invalid options
  • Accept and test for TableNameOrModel

These are things added by this PR so should be ready in this PR:

  • Check if createTableQuery is typed correctly

These don't really make sense to do in another PR IMO, it seems closely related to the goal of this PR:

  • Check if all tests make sense, the current tests are just copied from dialect specific tests and other expectations are added
  • Give tests better names

I don't think you need to keep this TODO. If we integration test each one of them, there is not real reason to unit test them. We should only test a few of them and the rest can be unit tests. It seems to already be what we're doing. If we're missing a specific test, we can instead add a TODO about it in the existing createTable integration suite

  • Make sure that all resulting queries are valid by adding integration tests for QueryInterface.createTable

@WikiRik
WikiRik marked this pull request as draft March 12, 2023 17:27
@WikiRik WikiRik self-assigned this Mar 12, 2023
@WikiRik

WikiRik commented Mar 19, 2023

Copy link
Copy Markdown
Member Author

I've overhauled the test suite so most TODOs are done. Next step is working on #15533 and after that I will check these and the QueryInterface.createTable tests again

@WikiRik
WikiRik marked this pull request as ready for review March 19, 2023 20:04
ephys
ephys previously approved these changes Mar 21, 2023
@WikiRik
WikiRik requested a review from ephys March 21, 2023 18:51
@WikiRik
WikiRik dismissed evanrittenhouse’s stale review March 21, 2023 18:52

Comments have been resolved and test suite overhauled

@WikiRik WikiRik changed the title meta: unify createTableQuery unit tests and type createTableQuery fix: type createTableQuery and overhaul unit test suite Mar 24, 2023
@WikiRik
WikiRik merged commit b5db02d into main Mar 24, 2023
@WikiRik
WikiRik deleted the WikiRik/create-table-query-unit-tests branch March 24, 2023 17:37
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.

3 participants