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

Change the alert specs to use webmock #494

Merged
merged 1 commit into from Jan 27, 2022
Merged

Change the alert specs to use webmock #494

merged 1 commit into from Jan 27, 2022

Conversation

barrucadu
Copy link
Contributor

@barrucadu barrucadu commented Jan 24, 2022

When implementing the unpublishing alert feature, we merged code with
a bug which was passing all the tests. The bug was that we were
calling a method in gds-api-adapters with incorrect arguments.

This bug passed the tests because the tests do not actually use
gds-api-adapters, they mock those methods and check that the mocked
methods are called appropriately.

This is a problem for two reasons:

  1. It let us write code which looked correct and even passed tests,
    but which could only have been verified as correct by consulting a
    different repository.

  2. An update to gds-api-adapters could change the method signature and
    our tests would continue to pass on the dependabot branch, even though
    merging it would break the service.

The point of testing is to catch bugs. If a test actively obscures
bugs, it should be fixed. This commit fixes the issue by using
webmock to check the actual calls we make to email-alert-api, rather
than stubbing the methods in gds-api-adapters.


Trello card

When implementing the unpublishing alert feature, we merged code with
a bug which was passing all the tests.  The bug was that we were
calling a method in gds-api-adapters with incorrect arguments.

This bug passed the tests because the tests do not actually use
gds-api-adapters, they mock those methods and check that the mocked
methods are called appropriately.

This is a problem for two reasons:

1. It let us write code which looked correct and even passed tests,
but which could only have been verified as correct by consulting a
different repository.

2. An update to gds-api-adapters could change the method signature and
our tests would continue to pass on the dependabot branch, even though
merging it would break the service.

The point of testing is to catch bugs.  If a test actively obscures
bugs, it should be fixed.  This commit fixes the issue by using
webmock to check the actual calls we make to email-alert-api, rather
than stubbing the methods in gds-api-adapters.
Copy link
Member

@alex9smith alex9smith left a comment

Choose a reason for hiding this comment

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

Sorry for the slow review, I didn't realise this was still open

@barrucadu barrucadu merged commit efc7200 into main Jan 27, 2022
@barrucadu barrucadu deleted the msw/webmock-alerts branch January 27, 2022 15:24
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.

None yet

2 participants