-
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.
* * `custom_message_type` support for subscription, publish, signal and files features. * `custom_message_type` field parsing support in history apis. * acceptance tests steps implementation for custom_message_type * set default retry policy to `Exponential` with default configuration. Fixed issue pointed out by PR #127 for limiting retry delay within maximum delay for linear policy * fix: linting and warnings * fix channel test for customMessageType * PubNub SDK v5.0.0 release. * update changelog --------- Co-authored-by: PubNub Release Bot <[email protected]>
- Loading branch information
1 parent
13ff777
commit a333aaa
Showing
29 changed files
with
291 additions
and
24 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
24 changes: 24 additions & 0 deletions
24
acceptance_tests/lib/src/steps/customMessageType/customMessageType_steps.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,24 @@ | ||
import '../../world.dart'; | ||
import 'package:gherkin/gherkin.dart'; | ||
|
||
import 'step_given_keyset.dart'; | ||
import 'step_then_error_response.dart'; | ||
import 'step_then_messagesContainsType.dart'; | ||
import 'step_then_receive.dart'; | ||
import 'step_then_success_response.dart'; | ||
import 'step_when_publish_with_type.dart'; | ||
import 'step_when_sendFile.dart'; | ||
import 'step_when_signal_with_type.dart'; | ||
import 'step_when_subscribe.dart'; | ||
|
||
final List<StepDefinitionGeneric<PubNubWorld>> customMessageTypeSteps = [ | ||
StepGivenTheDemoKeyset(), | ||
StepWhenIPublishWithCustomType(), | ||
StepThenIReceiveSuccessfulResponsePublish(), | ||
StepThenIReceivePublishErrorResponse(), | ||
StepWhenISignalWithCustomType(), | ||
StepWhenISubscribeChannalForCustomMessageType(), | ||
StepThenIReceiveMessagesInSubscriptionResponse(), | ||
StepThenReceivedMessagesHasMessageTypes(), | ||
StepWhenISendFileCustomType(), | ||
]; |
18 changes: 18 additions & 0 deletions
18
acceptance_tests/lib/src/steps/customMessageType/step_given_keyset.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,18 @@ | ||
import 'package:gherkin/gherkin.dart'; | ||
import 'package:pubnub/pubnub.dart'; | ||
|
||
import '../../world.dart'; | ||
|
||
class StepGivenTheDemoKeyset extends GivenWithWorld<PubNubWorld> { | ||
@override | ||
RegExp get pattern => RegExp(r'the demo keyset'); | ||
|
||
@override | ||
Future<void> executeStep() async { | ||
world.keyset = Keyset( | ||
publishKey: 'demo', | ||
subscribeKey: 'demo', | ||
userId: UserId('testCustomType') | ||
); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
acceptance_tests/lib/src/steps/customMessageType/step_then_error_response.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,21 @@ | ||
import 'package:gherkin/gherkin.dart'; | ||
import 'package:pubnub/pubnub.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
import '../../world.dart'; | ||
|
||
class StepThenIReceivePublishErrorResponse extends ThenWithWorld<PubNubWorld> { | ||
@override | ||
RegExp get pattern => RegExp(r'I receive an error response'); | ||
|
||
@override | ||
Future<void> executeStep() async { | ||
if(world.latestResultType == 'sendFile') { | ||
var result = world.latestResult as PublishFileMessageResult; | ||
this.expect(result.description?.toLowerCase(), contains('invalid_type')); | ||
} else { | ||
var result = world.latestResult as PublishException; | ||
this.expect(result.message.toLowerCase(), contains('invalid_type')); | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
acceptance_tests/lib/src/steps/customMessageType/step_then_messagesContainsType.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:test/expect.dart'; | ||
|
||
import '../../world.dart'; | ||
|
||
class StepThenReceivedMessagesHasMessageTypes | ||
extends Then2WithWorld<String, String, PubNubWorld> { | ||
@override | ||
RegExp get pattern => RegExp(r'response contains messages with {string} and {string} types'); | ||
|
||
@override | ||
Future<void> executeStep(String customMessageTypeOne, String customMessageTypeTwo) async { | ||
world.messages.forEach((message) { | ||
this.expect(message.customMessageType, anyOf([customMessageTypeOne, customMessageTypeTwo])); | ||
}); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
acceptance_tests/lib/src/steps/customMessageType/step_then_receive.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,14 @@ | ||
import 'package:gherkin/gherkin.dart'; | ||
|
||
import '../../world.dart'; | ||
|
||
class StepThenIReceiveMessagesInSubscriptionResponse | ||
extends Then1WithWorld<int, PubNubWorld> { | ||
@override | ||
RegExp get pattern => RegExp(r'I receive {int} messages in my subscribe response'); | ||
|
||
@override | ||
Future<void> executeStep(int count) async { | ||
expect(world.messages.length, 2); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
acceptance_tests/lib/src/steps/customMessageType/step_then_success_response.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,14 @@ | ||
import 'package:gherkin/gherkin.dart'; | ||
import 'package:test/expect.dart'; | ||
|
||
import '../../world.dart'; | ||
|
||
class StepThenIReceiveSuccessfulResponsePublish extends ThenWithWorld<PubNubWorld> { | ||
@override | ||
RegExp get pattern => RegExp(r'I receive a successful response'); | ||
|
||
@override | ||
Future<void> executeStep() async { | ||
this.expect(world.latestResultType, isNotNull); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
acceptance_tests/lib/src/steps/customMessageType/step_when_publish_with_type.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,24 @@ | ||
import 'package:gherkin/gherkin.dart'; | ||
|
||
import '../../world.dart'; | ||
|
||
class StepWhenIPublishWithCustomType extends When1WithWorld<String, PubNubWorld> { | ||
@override | ||
RegExp get pattern => RegExp(r'I publish message with {string} customMessageType'); | ||
|
||
@override | ||
Future<void> executeStep(String customMesageType) async { | ||
try { | ||
world.latestResult = await world.pubnub.publish( | ||
'test', | ||
'hello', | ||
keyset: world.keyset, | ||
customMessageType: customMesageType, | ||
); | ||
world.latestResultType = 'publish'; | ||
} catch (e) { | ||
world.latestResultType = 'publishWithCustomTypeFailure'; | ||
world.latestResult = e; | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
acceptance_tests/lib/src/steps/customMessageType/step_when_sendFile.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,21 @@ | ||
import 'package:gherkin/gherkin.dart'; | ||
|
||
import '../../world.dart'; | ||
|
||
class StepWhenISendFileCustomType | ||
extends When1WithWorld<String, PubNubWorld> { | ||
@override | ||
RegExp get pattern => | ||
RegExp(r'I send a file with {string} customMessageType'); | ||
|
||
@override | ||
Future<void> executeStep(String customMesageType) async { | ||
try { | ||
world.latestResult = await world.pubnub.files.sendFile('test', 'helloFile.txt', [12,16], customMessageType: customMesageType); | ||
world.latestResultType = 'sendFile'; | ||
} catch (e) { | ||
world.latestResultType = 'sendFileFailure'; | ||
world.latestResult = e; | ||
} | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
acceptance_tests/lib/src/steps/customMessageType/step_when_signal_with_type.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,26 @@ | ||
import 'package:gherkin/gherkin.dart'; | ||
|
||
import '../../world.dart'; | ||
|
||
class StepWhenISignalWithCustomType | ||
extends When1WithWorld<String, PubNubWorld> { | ||
@override | ||
RegExp get pattern => | ||
RegExp(r'I send a signal with {string} customMessageType'); | ||
|
||
@override | ||
Future<void> executeStep(String customMesageType) async { | ||
try { | ||
world.latestResult = await world.pubnub.signal( | ||
'test', | ||
'hello', | ||
keyset: world.keyset, | ||
customMessageType: customMesageType, | ||
); | ||
world.latestResultType = 'publish'; | ||
} catch (e) { | ||
world.latestResultType = 'publishWithCustomTypeFailure'; | ||
world.latestResult = e; | ||
} | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
acceptance_tests/lib/src/steps/customMessageType/step_when_subscribe.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 '../../world.dart'; | ||
|
||
class StepWhenISubscribeChannalForCustomMessageType | ||
extends When1WithWorld<String, PubNubWorld> { | ||
@override | ||
RegExp get pattern => | ||
RegExp(r'I subscribe to {string} channel'); | ||
|
||
@override | ||
Future<void> executeStep(String channel) async { | ||
try { | ||
var subscription = world.pubnub.subscribe(channels: {channel}); | ||
subscription.messages.listen((messageEnvelope) { | ||
world.messages.add(messageEnvelope); | ||
}); | ||
await Future.delayed(Duration(seconds: 2), () { | ||
subscription.dispose(); | ||
}); | ||
world.latestResultType = 'subscription'; | ||
} catch (e) { | ||
world.latestResultType = 'subscriptionFailure'; | ||
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
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
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
Oops, something went wrong.