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

feat: add DataSource.deleteAllModels() API #1759

Merged
merged 1 commit into from Jul 18, 2019

Conversation

@bajtos
Copy link
Member

commented Jul 18, 2019

When writing tests, for performance reasons we often want to reuse the same data-source instance for many tests suites. At the same time, we want to keep such test suites independent and allow them to reuse the same model name for different model classes.

Juggler does support redefinition of a model with the same name.

This change is adding a new API called dataSource.reset() that allows tests to remove all old models before creating new ones (typically from a before hook).

Related issues

This is very loosely related to strongloop/loopback-next#3387.

Checklist

  • New tests added or existing tests modified to cover all changes
  • Code conforms with the style
    guide

@bajtos bajtos added the feature label Jul 18, 2019

@bajtos bajtos added this to the July 2019 milestone milestone Jul 18, 2019

@bajtos bajtos requested review from raymondfeng and b-admike Jul 18, 2019

@bajtos bajtos requested review from dhmlau, emonddr, jannyHou and zbarbuto as code owners Jul 18, 2019

@bajtos bajtos self-assigned this Jul 18, 2019

@b-admike
Copy link
Member

left a comment

LGTM in terms of code and the reasons behind it. I suggest waiting for an approval from @raymondfeng before landing.

@b-admike
Copy link
Member

left a comment

Do we also want to update types/datasource.d.ts file as well for this API?

@bajtos

This comment has been minimized.

Copy link
Member Author

commented Jul 18, 2019

Do we also want to update types/datasource.d.ts file as well for this API?

Good catch! Of course we want to update typings too.

@bajtos bajtos force-pushed the feat/reset-datasource branch from fde6d6a to 1f8f100 Jul 18, 2019

@bajtos

This comment has been minimized.

Copy link
Member Author

commented Jul 18, 2019

Amended the commit to include changes in types/datasource.d.ts too.

@b-admike
Copy link
Member

left a comment

Nice 👍

lib/datasource.js Outdated Show resolved Hide resolved
feat: add DataSource.deleteAllModels() API
When writing tests, for performance reasons we often want to reuse
the same data-source instance for many tests suites. At the same time,
we want to keep such test suites independent and allow them to reuse
the same model name for different model classes.

Juggler does support redefinition of a model with the same name.

This change is adding a new API called that allows tests to remove all
old models before creating new ones. This API would be typically
called from a `before` hook.

Signed-off-by: Miroslav Bajtoš <mbajtoss@gmail.com>

@bajtos bajtos force-pushed the feat/reset-datasource branch from 1f8f100 to 78c5b12 Jul 18, 2019

@bajtos

This comment has been minimized.

Copy link
Member Author

commented Jul 18, 2019

@raymondfeng LGTY now?

@bajtos bajtos changed the title feat: add DataSource.reset() API feat: add DataSource.deleteAllModels() API Jul 18, 2019

@bajtos bajtos merged commit 6478c73 into master Jul 18, 2019

16 of 21 checks passed

[cis-jenkins] PR Builder Build finished.
Details
[cis-jenkins] downstream: loopback-connector-cloudant@master Failed! (78c5b12)
Details
[cis-jenkins] downstream: loopback-connector-mysql@master Failed! (78c5b12)
Details
[cis-jenkins] downstream: loopback-connector-oracle@master Failed! (78c5b12)
Details
continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
Commit Linter commits are all properly formatted
Details
PR Linter PR is up to date
Details
[cis-jenkins] downstream: loopback-connector-kv-redis@master Success! (78c5b12)
Details
[cis-jenkins] downstream: loopback-connector-mongodb@master Success! (78c5b12)
Details
[cis-jenkins] downstream: loopback-connector-mssql@master Success! (78c5b12)
Details
[cis-jenkins] downstream: loopback-connector-postgresql@master Success! (78c5b12)
Details
[cis-jenkins] x64 && linux && nvm,10 Success! (78c5b12)
Details
[cis-jenkins] x64 && linux && nvm,8 Success! (78c5b12)
Details
clahub All contributors have signed the Contributor License Agreement.
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
coverage/coveralls Coverage increased (+0.003%) to 84.572%
Details
loopback-datasource-juggler Success! (78c5b12)
Details
loopback-datasource-juggler/node=4.x,os=windows Success! (78c5b12)
Details
loopback-datasource-juggler/node=6.x,os=windows Success! (78c5b12)
Details
pr-builder
Details
security/snyk - package.json (StrongLoop) No manifest changes detected

@delete-merged-branch delete-merged-branch bot deleted the feat/reset-datasource branch Jul 18, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.