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

fix: deprecated callbacks passed to mongodb, in post model #680

Merged
merged 40 commits into from
Aug 29, 2023

Conversation

adrienjoly
Copy link
Member

@adrienjoly adrienjoly commented Aug 24, 2023

Contributes to #634.

@adrienjoly adrienjoly changed the title fix callbacks passed to mongodb, in post model fix: callbacks passed to mongodb, in post model Aug 24, 2023
@adrienjoly adrienjoly self-assigned this Aug 24, 2023
@adrienjoly adrienjoly changed the title fix: callbacks passed to mongodb, in post model fix: deprecated callbacks passed to mongodb, in post model Aug 24, 2023
cause: some refs were probably not detected earlier, because of complicated callback logic
contributes to #580.
@codacy-production
Copy link

codacy-production bot commented Aug 24, 2023

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
+1.95% 58.11%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (26cfb9f) 5131 3035 59.15%
Head commit (a720c47) 5128 (-3) 3133 (+98) 61.10% (+1.95%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#680) 74 43 58.11%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

… import("/Users/adrienjoly/Code/openwhyd/app/models/config")'`
…track` => make sure that db is cleared between each test
…isolated/independant from other tests of the suite
@adrienjoly
Copy link
Member Author

adrienjoly commented Aug 28, 2023

Note about the following FIXME comment:

FIXME: We are forced to use the ADMIN_USER, since DUMMY_USER is mutated by user.api.tests.js and the db cleanup seems to not work for the users collection.
May be initdb_testing.js is not up to date with the current schema?

I believe that I have reproduced that issue in fix test, to match with schema of posts, as seen in failing post API tests, only after they are run after playlist API tests (which mutate DUMMY_USER in the db). See logs: https://github.com/openwhyd/openwhyd/actions/runs/5998120167/job/16265796818?pr=680#step:6:172

After investigating locally:

  • posts test pass when they are run alone
  • when they are run after playlist tests, requests are rejected with 400 (badRequest) by handleRequest because user is an empty object. Hence the hypothesis of the test users not being properly reset between test suites.

EDIT: Indeed, tests work as expected when skipping the rename action nested test suite from test/api/playlist.api.tests.js (which call insertTestData in the user collection, with an altered version of DUMMY_USER).

Hypothesis: bad state reset could be caused by failed to kill by pid: kill ESRCH error after running each test of npm run test:api

@adrienjoly adrienjoly force-pushed the fix/deprecated-mongodb-calls-in-post-model branch from 07ca189 to f10f9ee Compare August 28, 2023 12:33
adrienjoly added a commit that referenced this pull request Aug 28, 2023
…685)

Contributes to #684.

* fix test helpers based on trouble while working on PR #680

* fix: check that we're on test database before refreshing db caches

* report cleanup errors if any

* fixtures: make test users immutable

* 🧹 `failed to kill by pid: kill ESRCH` errors when running integration/api tests

* skip flaky unit test

* migrate playlist API tests to `OpenwhydTestEnv`

* fix `listen EADDRINUSE: address already in use :::8080` when api tests are running on CI, with coverage
cf https://github.com/openwhyd/openwhyd/actions/runs/6000177975/job/16271736742#step:6:266

* refactor(fixtures): extract resetTestDb() from cleanup()

* ✨ use OpenwhydTestEnv.reset() instead of fixtures.cleanup(), in playlist API tests

* extract and increase timeout/tolerance for algolia (3rd-party) tests
cf `Exceeded timeout of 20000 ms for a hook` at https://github.com/openwhyd/openwhyd/actions/runs/6000432446/job/16272475960#step:5:81
@adrienjoly adrienjoly marked this pull request as ready for review August 29, 2023 15:32
@adrienjoly adrienjoly merged commit 8abd8d8 into main Aug 29, 2023
18 checks passed
@adrienjoly adrienjoly deleted the fix/deprecated-mongodb-calls-in-post-model branch August 29, 2023 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant