-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: missing customMessageType support in history (#129)
- Loading branch information
1 parent
a333aaa
commit 14fb57b
Showing
11 changed files
with
181 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
acceptance_tests/lib/src/steps/customMessageType/step_given_storage_enabled.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import 'package:gherkin/gherkin.dart'; | ||
import 'package:pubnub/pubnub.dart'; | ||
|
||
import '../../world.dart'; | ||
|
||
class StepGivenTheStorageEnabledKeyset extends GivenWithWorld<PubNubWorld> { | ||
@override | ||
RegExp get pattern => RegExp(r'the demo keyset with enabled storage'); | ||
|
||
@override | ||
Future<void> executeStep() async { | ||
world.keyset = Keyset( | ||
publishKey: 'demo', | ||
subscribeKey: 'demo', | ||
userId: UserId('testCustomType')); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
acceptance_tests/lib/src/steps/customMessageType/step_then_history_customMessageTypes.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import 'package:gherkin/gherkin.dart'; | ||
import 'package:test/expect.dart'; | ||
|
||
import '../../world.dart'; | ||
|
||
class StepThenHistoryReceivedMessagesHasCustomMessageTypes | ||
extends Then2WithWorld<String, String, PubNubWorld> { | ||
@override | ||
RegExp get pattern => RegExp( | ||
r'history response contains messages with {string} and {string} types'); | ||
|
||
@override | ||
Future<void> executeStep( | ||
String customMessageTypeOne, String customMessageTypeTwo) async { | ||
world.historyMessages.forEach((message) { | ||
this.expect(message.customMessageType, | ||
anyOf([customMessageTypeOne, customMessageTypeTwo])); | ||
}); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
acceptance_tests/lib/src/steps/customMessageType/step_then_history_messages.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import 'package:gherkin/gherkin.dart'; | ||
import 'package:test/expect.dart'; | ||
|
||
import '../../world.dart'; | ||
|
||
class StepThenHistoryReceivedMessagesHasMessageTypesInt | ||
extends Then2WithWorld<String, String, PubNubWorld> { | ||
@override | ||
RegExp get pattern => | ||
RegExp(r'history response contains messages with {string} and {string} message types'); | ||
|
||
@override | ||
Future<void> executeStep( | ||
String customMessageTypeOne, String customMessageTypeTwo) async { | ||
world.historyMessages.forEach((message) { | ||
this.expect(message.messageType, | ||
anyOf([customMessageTypeOne, customMessageTypeTwo])); | ||
}); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
acceptance_tests/lib/src/steps/customMessageType/step_then_no_CustomType.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// history response contains messages without customMessageType | ||
import 'package:gherkin/gherkin.dart'; | ||
import 'package:test/expect.dart'; | ||
|
||
import '../../world.dart'; | ||
|
||
class StepThenReceivedMessagesNoCustomMessageTypes | ||
extends ThenWithWorld<PubNubWorld> { | ||
@override | ||
RegExp get pattern => | ||
RegExp(r'history response contains messages without customMessageType'); | ||
|
||
@override | ||
Future<void> executeStep( | ||
) async { | ||
world.messages.forEach((message) { | ||
expect( | ||
message.customMessageType, | ||
null); | ||
}); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
acceptance_tests/lib/src/steps/customMessageType/step_when_fetchMessages.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import 'package:gherkin/gherkin.dart'; | ||
import 'package:pubnub/pubnub.dart'; | ||
|
||
import '../../world.dart'; | ||
|
||
class StepWhenFetchMessagesWithMessageType | ||
extends When1WithWorld<String, PubNubWorld> { | ||
@override | ||
RegExp get pattern => | ||
RegExp(r'I fetch message history with messageType for {string} channel'); | ||
|
||
@override | ||
Future<void> executeStep(String channel) async { | ||
try { | ||
var batchResult = await world.pubnub.batch.fetchMessages({channel}, | ||
includeMessageType: true); | ||
(world.latestResult as BatchHistoryResult).channels.keys.forEach( (c) => | ||
world.historyMessages.addAll(batchResult.channels[c] as Iterable<BatchHistoryResultEntry>) | ||
); | ||
world.latestResult = batchResult; | ||
world.latestResultType = 'fetchMessages'; | ||
} catch (e) { | ||
world.latestResultType = 'fetchMessagesWithMessageTypeTypeFailure'; | ||
world.latestResult = e; | ||
} | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
acceptance_tests/lib/src/steps/customMessageType/step_when_fetch_custom_channel.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import 'package:gherkin/gherkin.dart'; | ||
import 'package:pubnub/pubnub.dart'; | ||
|
||
import '../../world.dart'; | ||
|
||
class StepWhenFetchMessagesWithParams | ||
extends When3WithWorld<String,String, String, PubNubWorld> { | ||
@override | ||
RegExp get pattern => | ||
RegExp(r'I fetch message history with {string} set to {string} for {string} channel'); | ||
|
||
@override | ||
Future<void> executeStep(String includeCustomMessageType, String paramValue, String channel) async { | ||
try { | ||
var batchResult = await world.pubnub.batch | ||
.fetchMessages({channel}, includeCustomMessageType: bool.parse(paramValue)); | ||
(world.latestResult as BatchHistoryResult).channels.keys.forEach((c) => | ||
world.historyMessages.addAll( | ||
batchResult.channels[c] as Iterable<BatchHistoryResultEntry>)); | ||
world.latestResult = batchResult; | ||
world.latestResultType = 'fetchMessages'; | ||
} catch (e) { | ||
world.latestResultType = 'fetchMessagesWithMessageTypeTypeFailure'; | ||
world.latestResult = e; | ||
} | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
acceptance_tests/lib/src/steps/customMessageType/step_when_fetch_with_custom.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import 'package:gherkin/gherkin.dart'; | ||
import 'package:pubnub/pubnub.dart'; | ||
|
||
import '../../world.dart'; | ||
|
||
class StepWhenFetchMessagesWithCustomMessageType | ||
extends When1WithWorld<String, PubNubWorld> { | ||
@override | ||
RegExp get pattern => | ||
RegExp(r'When I fetch message history with customMessageType for {string} channel'); | ||
|
||
@override | ||
Future<void> executeStep(String channel) async { | ||
try { | ||
var batchResult = await world.pubnub.batch | ||
.fetchMessages({channel}, includeMessageType: true, includeCustomMessageType: true); | ||
(world.latestResult as BatchHistoryResult).channels.keys.forEach((c) => | ||
world.historyMessages.addAll( | ||
batchResult.channels[c] as Iterable<BatchHistoryResultEntry>)); | ||
world.latestResult = batchResult; | ||
world.latestResultType = 'fetchMessages'; | ||
} catch (e) { | ||
world.latestResultType = 'fetchMessagesWithMessageTypeTypeFailure'; | ||
world.latestResult = e; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters