Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions splitio/example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -150,28 +150,28 @@ packages:
path: ".."
relative: true
source: path
version: "0.1.6-rc.1"
version: "0.1.6"
splitio_android:
dependency: transitive
description:
path: "../../splitio_android"
relative: true
source: path
version: "0.1.6-rc.1"
version: "0.1.6"
splitio_ios:
dependency: transitive
description:
path: "../../splitio_ios"
relative: true
source: path
version: "0.1.6-rc.1"
version: "0.1.6"
splitio_platform_interface:
dependency: transitive
description:
path: "../../splitio_platform_interface"
relative: true
source: path
version: "1.3.0-rc.1"
version: "1.3.0"
stack_trace:
dependency: transitive
description:
Expand Down
76 changes: 76 additions & 0 deletions splitio/lib/split_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,46 @@ abstract class SplitClient {
Future<Map<String, String>> getTreatments(List<String> featureFlagNames,
[Map<String, dynamic> attributes = const {}]);

/// Convenience method to perform multiple evaluations by flag set. Returns a [Map] in
/// which the keys are feature flag names and the values are treatments.
///
/// A flag set needs to be specified in [flagSet].
///
/// Optionally, a [Map] can be specified with the [attributes] parameter to
/// take into account when evaluating.
Future<Map<String, String>> getTreatmentsByFlagSet(String flagSet,
[Map<String, dynamic> attributes = const {}]);

/// Convenience method to perform multiple evaluations by flag sets. Returns a [Map] in
/// which the keys are feature flag names and the values are treatments.
///
/// A list of flag sets needs to be specified in [flagSets].
///
/// Optionally, a [Map] can be specified with the [attributes] parameter to
/// take into account when evaluating.
Future<Map<String, String>> getTreatmentsByFlagSets(List<String> flagSets,
[Map<String, dynamic> attributes = const {}]);

/// Convenience method to perform multiple evaluations by flag set. Returns a [Map] in
/// which the keys are feature flag names and the values are [SplitResult] objects.
///
/// A flag set needs to be specified in [flagSet].
///
/// Optionally, a [Map] can be specified with the [attributes] parameter to
/// take into account when evaluating.
Future<Map<String, SplitResult>> getTreatmentsWithConfigByFlagSet(String flagSet,
[Map<String, dynamic> attributes = const {}]);

/// Convenience method to perform multiple evaluations by flag sets. Returns a [Map] in
/// which the keys are feature flag names and the values are [SplitResult] objects.
///
/// A list of flag sets needs to be specified in [flagSets].
///
/// Optionally, a [Map] can be specified with the [attributes] parameter to
/// take into account when evaluating.
Future<Map<String, SplitResult>> getTreatmentsWithConfigByFlagSets(List<String> flagSets,
[Map<String, dynamic> attributes = const {}]);

/// Convenience method to perform multiple evaluations. Returns a [Map] in
/// which the keys are feature flag names and the values are [SplitResult] objects.
///
Expand Down Expand Up @@ -185,6 +225,42 @@ class DefaultSplitClient implements SplitClient {
attributes: attributes);
}

@override
Future<Map<String, String>> getTreatmentsByFlagSet(String flagSet, [Map<String, dynamic> attributes = const {}]) {
return _platform.getTreatmentsByFlagSet(
matchingKey: _matchingKey,
bucketingKey: _bucketingKey,
flagSet: flagSet,
attributes: attributes);
}

@override
Future<Map<String, String>> getTreatmentsByFlagSets(List<String> flagSets, [Map<String, dynamic> attributes = const {}]) {
return _platform.getTreatmentsByFlagSets(
matchingKey: _matchingKey,
bucketingKey: _bucketingKey,
flagSets: flagSets,
attributes: attributes);
}

@override
Future<Map<String, SplitResult>> getTreatmentsWithConfigByFlagSet(String flagSet, [Map<String, dynamic> attributes = const {}]) {
return _platform.getTreatmentsWithConfigByFlagSet(
matchingKey: _matchingKey,
bucketingKey: _bucketingKey,
flagSet: flagSet,
attributes: attributes);
}

@override
Future<Map<String, SplitResult>> getTreatmentsWithConfigByFlagSets(List<String> flagSets, [Map<String, dynamic> attributes = const {}]) {
return _platform.getTreatmentsWithConfigByFlagSets(
matchingKey: _matchingKey,
bucketingKey: _bucketingKey,
flagSets: flagSets,
attributes: attributes);
}

@override
Future<bool> track(String eventType,
{String? trafficType,
Expand Down
9 changes: 6 additions & 3 deletions splitio/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@ flutter:
dependencies:
flutter:
sdk: flutter
splitio_android: ^0.1.6
splitio_ios: ^0.1.6
splitio_platform_interface: ^1.3.0
splitio_android: #^0.1.6
path: ../splitio_android
splitio_ios: #^0.1.6
path: ../splitio_ios
splitio_platform_interface: #^1.3.0
path: ../splitio_platform_interface

dev_dependencies:
flutter_test:
Expand Down
112 changes: 112 additions & 0 deletions splitio/test/splitio_client_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,118 @@ void main() {
'attributes': {'attr1': true}
});
});

test('getTreatmentsByFlagSet without attributes', () async {
SplitClient client = _getClient();

client.getTreatmentsByFlagSet('set_1');

expect(_platform.methodName, 'getTreatmentsByFlagSet');
expect(_platform.methodArguments, {
'flagSet': 'set_1',
'matchingKey': 'matching-key',
'bucketingKey': 'bucketing-key',
'attributes': {}
});
});

test('getTreatmentsByFlagSet with attributes', () async {
SplitClient client = _getClient();

client.getTreatmentsByFlagSet('set_1', {'attr1': true});

expect(_platform.methodName, 'getTreatmentsByFlagSet');
expect(_platform.methodArguments, {
'flagSet': 'set_1',
'matchingKey': 'matching-key',
'bucketingKey': 'bucketing-key',
'attributes': {'attr1': true}
});
});

test('getTreatmentsByFlagSets without attributes', () async {
SplitClient client = _getClient();

client.getTreatmentsByFlagSets(['set_1', 'set_2']);

expect(_platform.methodName, 'getTreatmentsByFlagSets');
expect(_platform.methodArguments, {
'flagSets': ['set_1', 'set_2'],
'matchingKey': 'matching-key',
'bucketingKey': 'bucketing-key',
'attributes': {}
});
});

test('getTreatmentsByFlagSets with attributes', () async {
SplitClient client = _getClient();

client.getTreatmentsByFlagSets(['set_1', 'set_2'], {'attr1': true});

expect(_platform.methodName, 'getTreatmentsByFlagSets');
expect(_platform.methodArguments, {
'flagSets': ['set_1', 'set_2'],
'matchingKey': 'matching-key',
'bucketingKey': 'bucketing-key',
'attributes': {'attr1': true}
});
});

test('getTreatmentsWithConfigByFlagSet without attributes', () async {
SplitClient client = _getClient();

client.getTreatmentsWithConfigByFlagSet('set_1');

expect(_platform.methodName, 'getTreatmentsWithConfigByFlagSet');
expect(_platform.methodArguments, {
'flagSet': 'set_1',
'matchingKey': 'matching-key',
'bucketingKey': 'bucketing-key',
'attributes': {}
});
});

test('getTreatmentsWithConfigByFlagSet with attributes', () async {
SplitClient client = _getClient();

client.getTreatmentsWithConfigByFlagSet('set_1', {'attr1': true});

expect(_platform.methodName, 'getTreatmentsWithConfigByFlagSet');
expect(_platform.methodArguments, {
'flagSet': 'set_1',
'matchingKey': 'matching-key',
'bucketingKey': 'bucketing-key',
'attributes': {'attr1': true}
});
});

test('getTreatmentsWithConfigByFlagSets without attributes', () async {
SplitClient client = _getClient();

client.getTreatmentsWithConfigByFlagSets(['set_1', 'set_2']);

expect(_platform.methodName, 'getTreatmentsWithConfigByFlagSets');
expect(_platform.methodArguments, {
'flagSets': ['set_1', 'set_2'],
'matchingKey': 'matching-key',
'bucketingKey': 'bucketing-key',
'attributes': {}
});
});

test('getTreatmentsWithConfigByFlagSets with attributes', () async {
SplitClient client = _getClient();

client.getTreatmentsWithConfigByFlagSets(['set_1', 'set_2'], {'attr1': true});

expect(_platform.methodName, 'getTreatmentsWithConfigByFlagSets');
expect(_platform.methodArguments, {
'flagSets': ['set_1', 'set_2'],
'matchingKey': 'matching-key',
'bucketingKey': 'bucketing-key',
'attributes': {'attr1': true}
});
});
});

group('track', () {
Expand Down
72 changes: 72 additions & 0 deletions splitio/test/splitio_platform_stub.dart
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,78 @@ class SplitioPlatformStub
return Future.value({});
}

@override
Future<Map<String, String>> getTreatmentsByFlagSet(
{required String matchingKey,
required String? bucketingKey,
required String flagSet,
Map<String, dynamic> attributes = const {}}) {
methodName = 'getTreatmentsByFlagSet';

methodArguments = {
'matchingKey': matchingKey,
'bucketingKey': bucketingKey,
'flagSet': flagSet,
'attributes': attributes,
};

return Future.value({});
}

@override
Future<Map<String, String>> getTreatmentsByFlagSets(
{required String matchingKey,
required String? bucketingKey,
required List<String> flagSets,
Map<String, dynamic> attributes = const {}}) {
methodName = 'getTreatmentsByFlagSets';

methodArguments = {
'matchingKey': matchingKey,
'bucketingKey': bucketingKey,
'flagSets': flagSets,
'attributes': attributes,
};

return Future.value({});
}

@override
Future<Map<String, SplitResult>> getTreatmentsWithConfigByFlagSet(
{required String matchingKey,
required String? bucketingKey,
required String flagSet,
Map<String, dynamic> attributes = const {}}) {
methodName = 'getTreatmentsWithConfigByFlagSet';

methodArguments = {
'matchingKey': matchingKey,
'bucketingKey': bucketingKey,
'flagSet': flagSet,
'attributes': attributes,
};

return Future.value({});
}

@override
Future<Map<String, SplitResult>> getTreatmentsWithConfigByFlagSets(
{required String matchingKey,
required String? bucketingKey,
required List<String> flagSets,
Map<String, dynamic> attributes = const {}}) {
methodName = 'getTreatmentsWithConfigByFlagSets';

methodArguments = {
'matchingKey': matchingKey,
'bucketingKey': bucketingKey,
'flagSets': flagSets,
'attributes': attributes,
};

return Future.value({});
}

@override
Stream<Impression> impressionsStream() {
methodName = 'impressionsStream';
Expand Down
3 changes: 2 additions & 1 deletion splitio_android/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ flutter:
dependencies:
flutter:
sdk: flutter
splitio_platform_interface: ^1.3.0
splitio_platform_interface: #^1.3.0
path: ../splitio_platform_interface

dev_dependencies:
flutter_test:
Expand Down
3 changes: 2 additions & 1 deletion splitio_ios/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ flutter:
dependencies:
flutter:
sdk: flutter
splitio_platform_interface: ^1.3.0
splitio_platform_interface: #^1.3.0
path: ../splitio_platform_interface

dev_dependencies:
flutter_test:
Expand Down