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
Merged

Conversation

bajtos
Copy link
Member

@bajtos bajtos 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 loopbackio/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 self-assigned this Jul 18, 2019
Copy link
Contributor

@b-admike b-admike left a comment

Choose a reason for hiding this comment

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

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

Copy link
Contributor

@b-admike b-admike left a comment

Choose a reason for hiding this comment

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

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

@bajtos
Copy link
Member Author

bajtos 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
Copy link
Member Author

bajtos commented Jul 18, 2019

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

Copy link
Contributor

@b-admike b-admike left a comment

Choose a reason for hiding this comment

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

Nice 👍

lib/datasource.js Outdated Show resolved Hide resolved
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š <[email protected]>
@bajtos
Copy link
Member Author

bajtos 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
@delete-merged-branch delete-merged-branch bot deleted the feat/reset-datasource branch July 18, 2019 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants