From 5657c3086907174a4ef1ffd8c914564eff54d448 Mon Sep 17 00:00:00 2001 From: umesh Date: Wed, 17 Nov 2021 14:32:16 -0500 Subject: [PATCH 1/2] workflows test --- .github/workflows/publish.yml | 14 +++++++++++ .github/workflows/test.yml | 45 ++++++++++++++++++++++++++++++++++ test/optimizely_dart_test.dart | 32 +++--------------------- 3 files changed, 63 insertions(+), 28 deletions(-) create mode 100644 .github/workflows/publish.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..70ead62 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,14 @@ +name: Publish + +on: + release: + types: [published] + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - uses: sakebook/actions-flutter-pub-publisher@v1.3.1 + with: + credential: ${{ secrets.CREDENTIAL_JSON }} \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..0511649 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,45 @@ + + +name: Test +on: + push: + branches: + - master + - development + pull_request: + +jobs: + test: + name: Test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - uses: subosito/flutter-action@v1 + with: + flutter-version: '2.0.4' + channel: 'stable' + - run: flutter pub get + - run: flutter test + + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - uses: subosito/flutter-action@v1 + with: + flutter-version: '2.0.4' + channel: 'stable' + - run: flutter pub get + - run: flutter analyze + + format: + name: Format + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - uses: subosito/flutter-action@v1 + with: + flutter-version: '2.0.4' + channel: 'stable' + - run: flutter format . --set-exit-if-changed \ No newline at end of file diff --git a/test/optimizely_dart_test.dart b/test/optimizely_dart_test.dart index f6330b4..53527e6 100644 --- a/test/optimizely_dart_test.dart +++ b/test/optimizely_dart_test.dart @@ -14,24 +14,14 @@ void main() { break; case 'isFeatureEnabled': var featureKey = methodCall.arguments['feature_key']; - var userId = methodCall.arguments['user_id']; - if (userId == 'user@pg.com' && featureKey == 'flutter') { + if (featureKey == 'flutter') { return true; } return false; case 'getAllFeatureVariables': var featureKey = methodCall.arguments['feature_key']; - var userId = methodCall.arguments['user_id']; - var attributes = methodCall.arguments['attributes']; - if (featureKey == 'calculator' && userId == 'user@pg.com') { - switch (attributes['platform']) { - case 'ios': - return {'calc_type': 'scientific'}; - case 'android': - return {'calc_type': 'basic'}; - default: - return {}; - } + if (featureKey == 'calculator') { + return {'calc_type': 'scientific'}; } return {}; default: @@ -60,28 +50,14 @@ void main() { final optimizelyPlugin = OptimizelyPlugin(); final enabled = await optimizelyPlugin.isFeatureEnabled( 'flutter', - 'user@pg.com', - {'platform': 'android'}, ); expect(enabled, true); }); - test('getAllFeatureVariablesAndroid', () async { + test('getAllFeatureVariables', () async { final optimizelyPlugin = OptimizelyPlugin(); var features = await optimizelyPlugin.getAllFeatureVariables( 'calculator', - 'user@pg.com', - {'platform': 'android'}, - ); - expect(features['calc_type'], 'basic'); - }); - - test('getAllFeatureVariablesApple', () async { - final optimizelyPlugin = OptimizelyPlugin(); - var features = await optimizelyPlugin.getAllFeatureVariables( - 'calculator', - 'user@pg.com', - {'platform': 'ios'}, ); expect(features['calc_type'], 'scientific'); }); From 7e82e5a54b5fe02bffc1b83a6a896551993d0c76 Mon Sep 17 00:00:00 2001 From: umesh Date: Wed, 17 Nov 2021 15:33:15 -0500 Subject: [PATCH 2/2] lint --- example/lib/main.dart | 5 ----- 1 file changed, 5 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index 72dd28b..1aa2188 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -44,9 +44,6 @@ class _MyAppState extends State { // Platform messages are asynchronous, so we initialize in an async method. Future getPriceFilterFlag() async { String priceFilterFlag; - // Platform messages may fail, so we use a try/catch PlatformException. - var platform = - Theme.of(context).platform.toString().split('.')[1].toLowerCase(); try { bool? featureEnabled = await optimizelyPlugin.isFeatureEnabled( 'price_filter', @@ -69,8 +66,6 @@ class _MyAppState extends State { Future getPriceFilterMinPrice() async { String minPriceVariable; Map variables; - var platform = - Theme.of(context).platform.toString().split('.')[1].toLowerCase(); try { variables = await optimizelyPlugin.getAllFeatureVariables( 'price_filter',