-
Notifications
You must be signed in to change notification settings - Fork 8
When subscribing to already subscribed channel or group should not resubscribe #384
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -84,8 +84,44 @@ class TransitionFromReceivingStateTest { | |
| } | ||
|
|
||
| @Test | ||
| fun can_transit_from_RECEIVING_to_RECEIVING_when_there_is_SUBSCRIPTION_CHANGED_event() { | ||
| fun can_transit_from_RECEIVING_to_RECEIVING_when_there_is_SUBSCRIPTION_CHANGED_event_with_different_channels_and_groups() { | ||
| // given | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I’d avoid adding comments like
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. // given, // when, // then is convention that exist in many test in this SDK. |
||
| val newChannels = setOf("Channel2", "Channel3") | ||
| val newChannelGroups = setOf("ChannelGroup2") | ||
|
|
||
| // when | ||
| val (state, invocations) = | ||
| transition( | ||
| SubscribeState.Receiving(channels, channelGroups, subscriptionCursor), | ||
| SubscribeEvent.SubscriptionChanged(newChannels, newChannelGroups), | ||
| ) | ||
|
|
||
| // then | ||
| Assertions.assertTrue(state is SubscribeState.Receiving) | ||
| state as SubscribeState.Receiving | ||
|
|
||
| assertEquals(newChannels, state.channels) | ||
| assertEquals(newChannelGroups, state.channelGroups) | ||
| assertEquals(subscriptionCursor, state.subscriptionCursor) | ||
| assertEquals( | ||
| setOf( | ||
| SubscribeEffectInvocation.CancelReceiveMessages, | ||
| SubscribeEffectInvocation.EmitStatus( | ||
| createSubscriptionChangedStatus( | ||
| state.subscriptionCursor, | ||
| newChannels, | ||
| newChannelGroups, | ||
| ), | ||
| ), | ||
| SubscribeEffectInvocation.ReceiveMessages(newChannels, newChannelGroups, subscriptionCursor), | ||
| ), | ||
| invocations, | ||
| ) | ||
| } | ||
|
|
||
| @Test | ||
| fun stays_in_RECEIVING_and_emits_status_without_resubscribing_when_SUBSCRIPTION_CHANGED_event_has_same_channels_and_groups() { | ||
| // given - channels and channelGroups are the same | ||
| // when | ||
| val (state, invocations) = | ||
| transition( | ||
|
|
@@ -100,17 +136,16 @@ class TransitionFromReceivingStateTest { | |
| assertEquals(channels, state.channels) | ||
| assertEquals(channelGroups, state.channelGroups) | ||
| assertEquals(subscriptionCursor, state.subscriptionCursor) | ||
| // Should only emit status - no cancel or new receive | ||
| assertEquals( | ||
| setOf( | ||
| SubscribeEffectInvocation.CancelReceiveMessages, | ||
| SubscribeEffectInvocation.EmitStatus( | ||
| createSubscriptionChangedStatus( | ||
| state.subscriptionCursor, | ||
| channels, | ||
| channelGroups, | ||
| ), | ||
| ), | ||
| SubscribeEffectInvocation.ReceiveMessages(channels, channelGroups, subscriptionCursor), | ||
| ), | ||
| invocations, | ||
| ) | ||
|
|
||
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's a pretty long name. What about
shouldEmitSubscriptionChangedWhenAlreadySubscribedor something similar?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.
shouldEmitSubscriptionChangedWhenAlreadySubscribedmisses important part that we want to make sure that there is no resubscribe.Name is pretty long but I think it serve the purpose of properly describing what the test does.
The test is complex and IMHO it is good that name describe its behaviour.
What do you think?