-
Notifications
You must be signed in to change notification settings - Fork 2
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
AB#4215 Add the repository for confirmation code with a delete function #1849
Conversation
backend/src/test/java/ca/gov/dtsstn/cdcp/api/data/repository/ConfirmationCodeRepositoryIT.java
Outdated
Show resolved
Hide resolved
backend/src/test/java/ca/gov/dtsstn/cdcp/api/data/repository/ConfirmationCodeRepositoryIT.java
Outdated
Show resolved
Hide resolved
assertThat(confirmationCodeRepository.findById("a6ea4925-f813-493e-80ec-a5b90ca28aaa")).isNotEmpty(); | ||
confirmationCodeRepository.deleteByExpiryDateLessThan(Instant.now()); | ||
assertThat(confirmationCodeRepository.findById("a6ea4925-f813-493e-80ec-a5b90ca28aaa")).isEmpty(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may be a good idea to verify that confirmation codes with an expiry date in the future and an expiry date with the current instant are not deleted.
backend/src/main/resources/db-migrations/h2/v0.1-[vendor]-data-init.sql
Outdated
Show resolved
Hide resolved
backend/src/main/java/ca/gov/dtsstn/cdcp/api/data/repository/ConfirmationCodeRepository.java
Outdated
Show resolved
Hide resolved
@ActiveProfiles("test") | ||
@Import({ DataSourceConfig.class }) | ||
@AutoConfigureTestDatabase(replace = Replace.NONE) | ||
public class ConfirmationCodeRepositoryIT { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something that I don't like about this test is that it relies on data that is in the data-init.sql
file.
I know that other tests do the same thing.. I feel that they're also not good tests.
What you should do, instead.. is do a findById(..)
and verify that the data doesn't exist, then insert using save(..)
and do another findById(..)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...same idea with the delete
method
0af8233
to
e5fa237
Compare
e5fa237
to
96aaa05
Compare
Close it for reference. @nicholas-ly will implement it later. |
Description
Add the repository for confirmation code with a delete function. This will delete all confirmation codes that have their expiry date less than the inserted time.
Related Azure Boards Work Items
AB#4215
Checklist
npm run format:check
npm run lint
npm run typecheck
npm run test:unit -- run
npm run test:e2e