Skip to content

wire-subsystems: Make mock for UserSubsystem depend on UserStore#5078

Merged
akshaymankar merged 5 commits intodevelopfrom
better-mock-user-subsystem
Mar 4, 2026
Merged

wire-subsystems: Make mock for UserSubsystem depend on UserStore#5078
akshaymankar merged 5 commits intodevelopfrom
better-mock-user-subsystem

Conversation

@akshaymankar
Copy link
Member

@akshaymankar akshaymankar commented Mar 3, 2026

https://wearezeta.atlassian.net/browse/WPB-22747

This way while testing other subsystems which may be writing to/reading from UserStore will remain consistent. This is only useful for AuthenticationSubsystem as of now.

Checklist

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

This way while testing other subsystems which may be writing to/reading from
UserStore will remain consistent. This is only useful for
AuthenticationSubsystem as of now.
@akshaymankar akshaymankar requested a review from a team as a code owner March 3, 2026 14:10
@zebot zebot added the ok-to-test Approved for running tests in CI, overrides not-ok-to-test if both labels exist label Mar 3, 2026

userSubsystemTestInterpreter :: [User] -> InterpreterFor UserSubsystem r
userSubsystemTestInterpreter initialUsers =
runInMemoryUserSubsytemInterpreter :: [StoredUser] -> InterpreterFor UserSubsystem r
Copy link
Contributor

Choose a reason for hiding this comment

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

why doesn't this need the Member constraints from inMemoryUserSubsystemInterpreter?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because it interprets the effects, or do I misunderstand the question?

userSubsystemTestInterpreter :: [User] -> InterpreterFor UserSubsystem r
userSubsystemTestInterpreter initialUsers =
runInMemoryUserSubsytemInterpreter :: [StoredUser] -> InterpreterFor UserSubsystem r
runInMemoryUserSubsytemInterpreter initialUsers =
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm confused: doesn't this go against the idea of shallow mocking, and more towards the MiniBackend approach?

But I'm all for it :)

Copy link
Member Author

@akshaymankar akshaymankar Mar 4, 2026

Choose a reason for hiding this comment

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

IMO It is still a shallow mock, I was debating whether to add all the UserStore stuff in here or just use the mock. It seemed to matter little, so I used the UserStore as a dependency.

Comment on lines -128 to +131
. interpretAuthenticationSubsystem (userSubsystemTestInterpreter preexistingUsers)
. inMemoryUserSubsystemInterpreter
. interpretAuthenticationSubsystem inMemoryUserSubsystemInterpreter
Copy link
Contributor

Choose a reason for hiding this comment

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

this is fine, but here's a nit-pick: in another place that i like better, we mutually recursive let bindings for auth and user subsystems. this makes it harder to accidentally only change on of the two occurrances of inMemoryUserSubsystemInterpreter.

Copy link
Member Author

@akshaymankar akshaymankar Mar 4, 2026

Choose a reason for hiding this comment

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

These are not mutually recursive, the mock interpreter for UserSubsystem doesn't depend on AuthenticationSubsystem. I think I might even be able to get rid of UserSubsystem from this stack.

@akshaymankar akshaymankar merged commit c47fb77 into develop Mar 4, 2026
10 checks passed
@akshaymankar akshaymankar deleted the better-mock-user-subsystem branch March 4, 2026 10:48
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.

4 participants