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

Mock combinators #3014

Merged
merged 7 commits into from
Jan 25, 2023
Merged

Mock combinators #3014

merged 7 commits into from
Jan 25, 2023

Conversation

pcapriotti
Copy link
Contributor

This PR introduces a very simple system for specifying federation mocks in a composable way. This replaces previous attempts (in Galley) that were only adopted in a few tests. All instances of mocked federator are now using the new system.

The system itself is a super-minimalistic "web framework" of sorts, based on a ReaderT FederatedRequest MaybeT monad transformer. You use guard to expect a certain request, and the Alternative combinators to specify multiple responses based on various criteria.

Checklist

  • Add a new entry in an appropriate subdirectory of changelog.d
  • Read and follow the PR guidelines

@pcapriotti pcapriotti temporarily deployed to cachix January 24, 2023 14:56 — with GitHub Actions Inactive
@pcapriotti pcapriotti temporarily deployed to cachix January 24, 2023 14:56 — with GitHub Actions Inactive
@pcapriotti pcapriotti marked this pull request as ready for review January 24, 2023 14:56
@pcapriotti pcapriotti temporarily deployed to cachix January 24, 2023 14:56 — with GitHub Actions Inactive
@pcapriotti pcapriotti temporarily deployed to cachix January 24, 2023 14:56 — with GitHub Actions Inactive
@zebot zebot added the ok-to-test Approved for running tests in CI, overrides not-ok-to-test if both labels exist label Jan 24, 2023
@mdimjasevic mdimjasevic self-requested a review January 24, 2023 15:00
@pcapriotti pcapriotti temporarily deployed to cachix January 24, 2023 15:58 — with GitHub Actions Inactive
@pcapriotti pcapriotti temporarily deployed to cachix January 24, 2023 15:58 — with GitHub Actions Inactive
@smatting smatting self-requested a review January 25, 2023 08:20
@pcapriotti pcapriotti temporarily deployed to cachix January 25, 2023 09:08 — with GitHub Actions Inactive
@pcapriotti pcapriotti temporarily deployed to cachix January 25, 2023 09:08 — with GitHub Actions Inactive
@pcapriotti pcapriotti temporarily deployed to cachix January 25, 2023 09:11 — with GitHub Actions Inactive
@pcapriotti pcapriotti temporarily deployed to cachix January 25, 2023 09:11 — with GitHub Actions Inactive
(FederatedRequest -> a) ->
TestM b ->
TestM (b, [FederatedRequest])
withTempMockFederator resp = withTempMockFederator' $ pure . encode . resp
Copy link
Contributor

Choose a reason for hiding this comment

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

Given that withTempMockFederator is gone, how about renaming the remaining withTempMockFederator' to withTempMockFederator?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not gone, it's the low-level function that is used by withTempMockFederator'. We could consider condensing all of these into a single function that takes a Mock parameter, but I would leave it for another PR.

services/galley/test/integration/API/MLS.hs Outdated Show resolved Hide resolved
services/galley/test/integration/API/Federation.hs Outdated Show resolved Hide resolved
services/galley/test/integration/API/Federation.hs Outdated Show resolved Hide resolved
@pcapriotti pcapriotti temporarily deployed to cachix January 25, 2023 10:02 — with GitHub Actions Inactive
@pcapriotti pcapriotti temporarily deployed to cachix January 25, 2023 10:02 — with GitHub Actions Inactive
@pcapriotti pcapriotti force-pushed the pcapriotti/mock-utilities branch from 8ca5fd6 to 0739f2b Compare January 25, 2023 10:03
@pcapriotti pcapriotti temporarily deployed to cachix January 25, 2023 10:03 — with GitHub Actions Inactive
@pcapriotti pcapriotti temporarily deployed to cachix January 25, 2023 10:03 — with GitHub Actions Inactive
@pcapriotti pcapriotti force-pushed the pcapriotti/mock-utilities branch from 0739f2b to ccfc113 Compare January 25, 2023 10:04
@pcapriotti pcapriotti temporarily deployed to cachix January 25, 2023 10:04 — with GitHub Actions Inactive
@pcapriotti pcapriotti temporarily deployed to cachix January 25, 2023 10:04 — with GitHub Actions Inactive
@pcapriotti pcapriotti force-pushed the pcapriotti/mock-utilities branch from ccfc113 to beead90 Compare January 25, 2023 13:04
@pcapriotti pcapriotti temporarily deployed to cachix January 25, 2023 13:04 — with GitHub Actions Inactive
@pcapriotti pcapriotti temporarily deployed to cachix January 25, 2023 13:04 — with GitHub Actions Inactive
@pcapriotti pcapriotti merged commit f6b2f93 into develop Jan 25, 2023
@pcapriotti pcapriotti deleted the pcapriotti/mock-utilities branch January 25, 2023 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ok-to-test Approved for running tests in CI, overrides not-ok-to-test if both labels exist
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants