13
13
* permissions and limitations under the License.
14
14
*/
15
15
16
- import 'package:amplify_analytics_pinpoint/method_channel_amplify .dart' ;
16
+ import 'package:amplify_datastore/amplify_datastore .dart' ;
17
17
import 'package:amplify_flutter/amplify_flutter.dart' ;
18
18
import 'package:amplify_flutter/src/amplify_impl.dart' ;
19
+ import 'package:amplify_test/test_models/ModelProvider.dart' ;
19
20
import 'package:flutter/services.dart' ;
20
21
import 'package:flutter_test/flutter_test.dart' ;
21
22
@@ -24,10 +25,8 @@ void main() {
24
25
Amplify = MethodChannelAmplify ();
25
26
26
27
const MethodChannel channel = MethodChannel ('com.amazonaws.amplify/amplify' );
27
- const MethodChannel storageChannel =
28
- MethodChannel ('com.amazonaws.amplify/storage_s3' );
29
- const MethodChannel analyticsChannel =
30
- MethodChannel ('com.amazonaws.amplify/analytics_pinpoint' );
28
+ const MethodChannel dataStoreChannel =
29
+ MethodChannel ('com.amazonaws.amplify/datastore' );
31
30
var platformConfigured = false ;
32
31
33
32
// Test data
@@ -61,27 +60,23 @@ void main() {
61
60
throw PlatformException (code: 'AmplifyAlreadyConfiguredException' );
62
61
}
63
62
});
64
- storageChannel.setMockMethodCallHandler ((MethodCall methodCall) async {
65
- return true ;
66
- });
67
- analyticsChannel.setMockMethodCallHandler ((MethodCall methodCall) async {
63
+ dataStoreChannel.setMockMethodCallHandler ((MethodCall methodCall) async {
68
64
return true ;
69
65
});
70
66
// We want to instantiate a new instance for each test so we start
71
67
// with a fresh state as `Amplify` singleton holds a state.
72
68
amplify = MethodChannelAmplify ();
73
69
AmplifyClass .instance = amplify;
74
70
75
- // We only use Auth and Analytics category for testing this class.
71
+ // We only use Auth and DataStore category for testing this class.
76
72
// Clear out their plugins before each test for a fresh state.
77
73
Amplify .Auth .reset ();
78
- Amplify .Analytics .reset ();
74
+ Amplify .DataStore .reset ();
79
75
});
80
76
81
77
tearDown (() {
82
78
channel.setMockMethodCallHandler (null );
83
- storageChannel.setMockMethodCallHandler (null );
84
- analyticsChannel.setMockMethodCallHandler (null );
79
+ dataStoreChannel.setMockMethodCallHandler (null );
85
80
});
86
81
87
82
test ('before calling configure, isConfigure should be false' , () {
@@ -132,39 +127,44 @@ void main() {
132
127
test ('adding multiple plugins using addPlugins method doesn\' t throw' ,
133
128
() async {
134
129
await amplify.addPlugins ([
135
- AmplifyAnalyticsPinpointMethodChannel ( ),
136
- AmplifyAnalyticsPinpointMethodChannel ( ),
130
+ AmplifyDataStore (modelProvider : ModelProvider .instance ),
131
+ AmplifyDataStore (modelProvider : ModelProvider .instance ),
137
132
]);
138
133
await amplify.configure (validJsonConfiguration);
139
134
expect (amplify.isConfigured, true );
140
135
});
141
136
142
137
test ('adding single plugins using addPlugin method doesn\' t throw' , () async {
143
- await amplify.addPlugin (AmplifyAnalyticsPinpointMethodChannel ());
138
+ await amplify
139
+ .addPlugin (AmplifyDataStore (modelProvider: ModelProvider .instance));
144
140
await amplify.configure (validJsonConfiguration);
145
141
expect (amplify.isConfigured, true );
146
142
});
147
143
148
144
test ('adding multiple plugins from same Analytic category throws exception' ,
149
145
() async {
150
- await amplify.addPlugin (AmplifyAnalyticsPinpointMethodChannel ());
146
+ await amplify
147
+ .addPlugin (AmplifyDataStore (modelProvider: ModelProvider .instance));
151
148
expect (
152
- amplify.addPlugin (AmplifyAnalyticsPinpointMethodChannel ()),
149
+ amplify
150
+ .addPlugin (AmplifyDataStore (modelProvider: ModelProvider .instance)),
153
151
throwsA (
154
152
isA <AmplifyException >().having (
155
153
(e) => e.toString (),
156
154
'toString' ,
157
- contains ('Analytics plugin has already been added' ),
155
+ contains ('DataStore plugin has already been added' ),
158
156
),
159
157
),
160
158
);
161
159
});
162
160
163
161
test ('adding plugins after configure throws an exception' , () async {
164
- await amplify.addPlugin (AmplifyAnalyticsPinpointMethodChannel ());
162
+ await amplify
163
+ .addPlugin (AmplifyDataStore (modelProvider: ModelProvider .instance));
165
164
await amplify.configure (validJsonConfiguration);
166
165
try {
167
- await amplify.addPlugin (AmplifyAnalyticsPinpointMethodChannel ());
166
+ await amplify
167
+ .addPlugin (AmplifyDataStore (modelProvider: ModelProvider .instance));
168
168
} catch (e) {
169
169
expect (e, amplifyAlreadyConfiguredForAddPluginException);
170
170
expect (amplify.isConfigured, true );
0 commit comments