Skip to content

Make API logic testable, and start testing some #23

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

Merged
merged 7 commits into from
Mar 8, 2023

Conversation

gnprice
Copy link
Member

@gnprice gnprice commented Mar 6, 2023

This is motivated just now by #21 by way of a couple of steps of yak-shaving (while #21 is itself yak-shaving for #13 which is for #11.) But it's also something we'll clearly want in any case.

For #21, we'll want some logic where the GlobalStore keeps around a collection of PerAccountStores, and when asked can pull out an existing one or load up a new one as needed. Because the loading is async (it involves talking to the server to fetch initial data; in the future it might start by reading a local snapshot from a database, but that'll also be async), the logic to prevent two concurrent calls from redundantly both doing the work is a bit more than trivial. I wrote up that logic and then figured it should have a test.

But the test shouldn't go try to talk to an actual Zulip server. So we'll need a way to swap in a fake implementation of talking to the server, for tests. This gets us part of the way there, far enough to write a few tests to validate that it works.

Copy link
Collaborator

@chrisbobbe chrisbobbe left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM! Please merge at will.

Subject<Message> get message => has((e) => e.message, 'message');
}

extension HeartbeatEventChecks on Subject<HeartbeatEvent> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: doubled space

@gnprice
Copy link
Member Author

gnprice commented Mar 8, 2023

Thanks! Merging with that fix.

@gnprice gnprice merged commit cf5d6d3 into zulip:main Mar 8, 2023
@gnprice gnprice deleted the pr-test-api branch March 8, 2023 00:05
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.

2 participants