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

test(sample-07): added unit tests #8044

Merged
merged 20 commits into from
Oct 21, 2021

Conversation

Tony133
Copy link
Contributor

@Tony133 Tony133 commented Sep 7, 2021

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior?

Issue Number: #1539

What is the new behavior?

Added unit tests in sample 07-sequelize

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

This PR, added unit tests in sample 07-sequelize

@coveralls
Copy link

coveralls commented Sep 7, 2021

Pull Request Test Coverage Report for Build 1e576ed5-2b5b-4dd5-a96a-d75a1b2b2cd7

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 94.203%

Totals Coverage Status
Change from base Build fd63d16d-fc64-4297-8832-ec429dc112f0: 0.0%
Covered Lines: 5655
Relevant Lines: 6003

💛 - Coveralls

@Tony133
Copy link
Contributor Author

Tony133 commented Oct 6, 2021

Conflicts resolved

Copy link
Member

@jmcdo29 jmcdo29 left a comment

Choose a reason for hiding this comment

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

The rest of the tests look good, just remove the one I mentioned or change it so it's mocking the sequelize functionality

sample/07-sequelize/src/users/users.service.spec.ts Outdated Show resolved Hide resolved
Copy link
Member

@jmcdo29 jmcdo29 left a comment

Choose a reason for hiding this comment

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

Just a few more changes I noticed

sample/07-sequelize/src/users/users.controller.spec.ts Outdated Show resolved Hide resolved
sample/07-sequelize/src/users/users.controller.spec.ts Outdated Show resolved Hide resolved
Copy link
Member

@jmcdo29 jmcdo29 left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -13,6 +14,7 @@ import { UsersModule } from './users/users.module';
database: 'test',
autoLoadModels: true,
synchronize: true,
models: [User],
Copy link
Member

Choose a reason for hiding this comment

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

Why is this needed? (and how can we avoid making this change)

Copy link
Contributor Author

@Tony133 Tony133 Oct 18, 2021

Choose a reason for hiding this comment

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

I followed the directions in the documentation: https://docs.nestjs.com/techniques/database#models ,
by adding the models in SequelizeModule.forRoot({...})

Copy link
Member

Choose a reason for hiding this comment

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

This shouldn't be required when autoLoadModels is set to true

Copy link
Contributor Author

@Tony133 Tony133 Oct 19, 2021

Choose a reason for hiding this comment

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

I wouldn't want to be wrong, but in sequelize version 5, registering the model in SequelizeModule.forRoot ({...}) was an alternative to extending the Model class, like this example export class Post extends Model<Post> {.... }.

Now from version 6, under the hood of sequelize something seems to have changed, so as you said autoLoadModels: true automatically loads the Modules if set to true, similar to TypeORM, now I tried to remove models:[] and it seems to work.

Maybe we should update the documents for this, what do you think?

Then I wanted to ask you but is the models:[] setting still useful to use? maybe you could remove it as a setting?

@Tony133
Copy link
Contributor Author

Tony133 commented Oct 20, 2021

Conflicts resolved in package.json👍

@Tony133
Copy link
Contributor Author

Tony133 commented Oct 21, 2021

Conflicts resolved in package.json👍, however I have removed in a commit models: [] in SequelizeModule.forRoot({})

@kamilmysliwiec kamilmysliwiec merged commit 2b5d0cf into nestjs:master Oct 21, 2021
@kamilmysliwiec
Copy link
Member

LGTM

@Tony133 Tony133 deleted the test/sample-07-sequelize branch July 9, 2022 13:19
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.

5 participants