Skip to content

Commit

Permalink
Merge pull request #49 from Unleash/fix-payload-stringify
Browse files Browse the repository at this point in the history
fix: payload stringify in bootstrap
  • Loading branch information
sjaanus authored Jun 26, 2024
2 parents cb9e3e7 + b304560 commit 487fba8
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 11 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.5.3

* Fix: payload stringify in bootstrap

## 1.5.2

* Chore: update dependency range on shared_preferences and uuid
Expand Down
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,13 @@ final unleash = UnleashClient(
* If `bootstrapOverride` is `true` (by default), any local cached data will be overridden with the bootstrap specified.
* If `bootstrapOverride` is `false` any local cached data will not be overridden unless the local cache is empty.

## Useful commands for development

* run tests: `flutter test`
* format code: `dart format lib test`
* analyse code: `flutter analyze lib test`
* run example app (from inside the `example` dir): `flutter run`
* publish new version (update manually first depending on semver): `dart pub publish`
## Release guide
* Run tests: `flutter test`
* Format code: `dart format lib test`
* Analyse code: `flutter analyze lib test`
* (optional) run example app (from inside the `example` dir): `flutter run`
* Bump up the version in `pubspec.yaml`
* Update the `CHANGELOG.md`
* Create a PR in new branch, merge it to main
* Publish new version from tip of main: `dart pub publish`
2 changes: 1 addition & 1 deletion lib/variant.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Variant {
}

Map<String, dynamic> toMap() {
return {'name': name, 'enabled': enabled, 'payload': payload};
return {'name': name, 'enabled': enabled, 'payload': payload?.toMap()};
}

@override
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: A Flutter/Dart client that can be used together with the unleash-pr
homepage: https://github.com/Unleash/unleash_proxy_client_flutter
repository: https://github.com/Unleash/unleash_proxy_client_flutter
issue_tracker: https://github.com/Unleash/unleash_proxy_client_flutter
version: 1.5.2
version: 1.5.3

environment:
sdk: ">=2.18.0 <4.0.0"
Expand Down
3 changes: 2 additions & 1 deletion test/pase_toggles_test.dart → test/parse_toggles_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ void main() {
]
}''';

Map<String, ToggleConfig> result = parseToggles(mockData);
Map<String, ToggleConfig> result =
parseToggles(stringifyToggles(parseToggles(mockData)));

expect(result.length, 4);

Expand Down
8 changes: 6 additions & 2 deletions test/unleash_proxy_client_flutter_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:http/http.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:unleash_proxy_client_flutter/in_memory_storage_provider.dart';
import 'package:unleash_proxy_client_flutter/payload.dart';
import 'package:unleash_proxy_client_flutter/shared_preferences_storage_provider.dart';
import 'package:unleash_proxy_client_flutter/toggle_config.dart';
import 'package:unleash_proxy_client_flutter/unleash_context.dart';
Expand Down Expand Up @@ -1015,7 +1016,10 @@ void main() {
'flutter-on': ToggleConfig(
enabled: true,
impressionData: false,
variant: Variant(enabled: true, name: 'variant-name'))
variant: Variant(
enabled: true,
name: 'variant-name',
payload: Payload(type: "string", value: "someValue")))
},
fetcher: getMock);

Expand All @@ -1039,7 +1043,7 @@ void main() {

expect(events, ['initialized', 'ready']);
expect(storageToggles,
'{"toggles":[{"name":"flutter-on","enabled":true,"impressionData":false,"variant":{"name":"variant-name","enabled":true,"payload":null}}]}');
'{"toggles":[{"name":"flutter-on","enabled":true,"impressionData":false,"variant":{"name":"variant-name","enabled":true,"payload":{"type":"string","value":"someValue"}}}]}');
});

test('should not emit ready event twice when using bootstrap', () async {
Expand Down

0 comments on commit 487fba8

Please sign in to comment.