Skip to content
This repository has been archived by the owner on Aug 7, 2023. It is now read-only.

chore: workflows test #8

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
14 changes: 14 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -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 }}
45 changes: 45 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -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
5 changes: 0 additions & 5 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ class _MyAppState extends State<MyApp> {
// Platform messages are asynchronous, so we initialize in an async method.
Future<void> 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',
Expand All @@ -69,8 +66,6 @@ class _MyAppState extends State<MyApp> {
Future<void> getPriceFilterMinPrice() async {
String minPriceVariable;
Map<String, dynamic> variables;
var platform =
Theme.of(context).platform.toString().split('.')[1].toLowerCase();
try {
variables = await optimizelyPlugin.getAllFeatureVariables(
'price_filter',
Expand Down
32 changes: 4 additions & 28 deletions test/optimizely_dart_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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');
});
Expand Down