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

Integration tests state setup #11

Open
naz opened this issue Nov 23, 2018 · 4 comments
Open

Integration tests state setup #11

naz opened this issue Nov 23, 2018 · 4 comments

Comments

@naz
Copy link
Contributor

naz commented Nov 23, 2018

The bigger the test suite for integration tests becomes, the harder it's to achieve a certain state for a test case. Opening this issue as a ground for discussion on how things could be improved.

As an example, checking if a certain record belongs to a specific relational filter takes to look up:

  1. posts collection in base.json,
  2. compare it with records in many-to-many.json
  3. go back to base.json and check tags collection there

When there are multiple records/properties matching this 3 step process becomes over cumbersome.

One of the thoughts around making things easier to check would be not having a global state like base.json but a set of helper functions that would set up the state in few steps. The downside of this approach is more work in the test case setup, but than it's a lot more clear which cases are being expected to be returned. Hard to find a good middle ground here 🤷‍♂️

Don't have any specific recepie and current approach is good enough :) Just opening this issue as a discussion to try improve future test suite maintenance and development.

@ErisDS
Copy link
Member

ErisDS commented Nov 26, 2018

I don't really understand why the same posts, tags and users are being redefined in some of the files, or why other fixture files exist but are empty.

Seems like the original concept got misused, but I also see that all the code to have naming logic for each test suite got ripped out.

@naz
Copy link
Contributor Author

naz commented Nov 27, 2018

@ErisDS atm, the empty files are: one-to-one and one-to-many relations fixtures. They are empty as we don't have any support for those relations just yet and will be filled out as we need them. As for 'many-to-many-extended' fixture redefining state, it hasn't been worked on and I did misunderstand it's usage in the beginning, will clean that up.

Seems like the original concept got misused, but I also see that all the code to have naming logic for each test suite got ripped out.

Which part are you referring to exactly?

@ErisDS
Copy link
Member

ErisDS commented Nov 27, 2018

This commit results in quite a change to the idea behind the test framework that was in place to start with:

TryGhost/mongo-knex@2e7777b

@kirrg001 kirrg001 removed their assignment Dec 4, 2018
@kirrg001
Copy link
Contributor

kirrg001 commented Dec 4, 2018

I think the test env is fine as it is? We define resources in base.json and add relations in a separate file. Resources don't need to be duplicated. I agree to your point that you have to have two files open to compare which resource has which relations, buuut for me personally speaking, this is nothing which annoys or annoyed me 🙂

There are for sure ideas/improvements we can add to any test env we have 👻I am not sure it's worth leaving this issue open? 🤔 I doubt somebody will have time to optimise the test env 🤓 What i experienced in the past: most of the time test env improvements happen natuarly. If you need them, you add them. If something sucks while you write tests, you change it.

@gargol feel free to either leave the issue open or close 🤘🏽

The only thing we could do quickly is to remove the empty fixture files e.g. https://github.com/NexesJS/mongo-knex/blob/master/test/integration/suite1/fixtures/one-to-many.json? 🤔 This is maybe a little bit confusing. These test cases are anyway not supported and skipped.

Seems like the original concept got misused, but I also see that all the code to have naming logic for each test suite got ripped out.

All of the original test env is still in place, except of the smart file name detection. When i was trying to get the tests fully working i had trouble working with it.

@kirrg001 kirrg001 unassigned naz Dec 4, 2018
kirrg001 referenced this issue in TryGhost/mongo-knex Dec 5, 2018
refs https://github.com/NexesJS/mongo-knex/issues/19#issuecomment-444237523

- one-to-many and one-to-one is not implemented
- removed related files
- they were empty anyway
daniellockyer referenced this issue Mar 1, 2022
refs https://github.com/NexesJS/mongo-knex/issues/19#issuecomment-444237523

- one-to-many and one-to-one is not implemented
- removed related files
- they were empty anyway
@daniellockyer daniellockyer transferred this issue from TryGhost/mongo-knex Mar 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants