1
1
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
// SPDX-License-Identifier: Apache-2.0
3
3
4
- import 'package:amplify_datastore/amplify_datastore.dart' ;
5
4
import 'package:amplify_flutter/amplify_flutter.dart' ;
6
5
import 'package:amplify_flutter/src/amplify_impl.dart' ;
7
- import 'package:amplify_test/test_models/ModelProvider.dart' ;
8
6
import 'package:flutter/services.dart' ;
9
7
import 'package:flutter_test/flutter_test.dart' ;
10
8
@@ -18,6 +16,8 @@ final throwsPluginNotAddedError = throwsA(
18
16
),
19
17
);
20
18
19
+ class MockPlugin extends AuthPluginInterface {}
20
+
21
21
void main () {
22
22
TestWidgetsFlutterBinding .ensureInitialized ();
23
23
Amplify = MethodChannelAmplify ();
@@ -120,44 +120,24 @@ void main() {
120
120
test ('adding multiple plugins using addPlugins method doesn\' t throw' ,
121
121
() async {
122
122
await amplify.addPlugins ([
123
- AmplifyDataStore (modelProvider : ModelProvider .instance ),
124
- AmplifyDataStore (modelProvider : ModelProvider .instance ),
123
+ MockPlugin ( ),
124
+ MockPlugin ( ),
125
125
]);
126
126
await amplify.configure (validJsonConfiguration);
127
127
expect (amplify.isConfigured, true );
128
128
});
129
129
130
130
test ('adding single plugins using addPlugin method doesn\' t throw' , () async {
131
- await amplify
132
- .addPlugin (AmplifyDataStore (modelProvider: ModelProvider .instance));
131
+ await amplify.addPlugin (MockPlugin ());
133
132
await amplify.configure (validJsonConfiguration);
134
133
expect (amplify.isConfigured, true );
135
134
});
136
135
137
- test ('adding multiple plugins from same Analytic category throws exception' ,
138
- () async {
139
- await amplify
140
- .addPlugin (AmplifyDataStore (modelProvider: ModelProvider .instance));
141
- expect (
142
- amplify
143
- .addPlugin (AmplifyDataStore (modelProvider: ModelProvider .instance)),
144
- throwsA (
145
- isA <PluginError >().having (
146
- (e) => e.toString (),
147
- 'toString' ,
148
- contains ('DataStore plugin has already been added' ),
149
- ),
150
- ),
151
- );
152
- });
153
-
154
136
test ('adding plugins after configure throws an exception' , () async {
155
- await amplify
156
- .addPlugin (AmplifyDataStore (modelProvider: ModelProvider .instance));
137
+ await amplify.addPlugin (MockPlugin ());
157
138
await amplify.configure (validJsonConfiguration);
158
139
try {
159
- await amplify
160
- .addPlugin (AmplifyDataStore (modelProvider: ModelProvider .instance));
140
+ await amplify.addPlugin (MockPlugin ());
161
141
} catch (e) {
162
142
expect (e, amplifyAlreadyConfiguredForAddPluginException);
163
143
expect (amplify.isConfigured, true );
0 commit comments