13
13
* permissions and limitations under the License.
14
14
*/
15
15
16
+ import 'package:amplify_datastore/amplify_datastore.dart' ;
16
17
import 'package:amplify_datastore_example/models/ModelProvider.dart' ;
17
18
import 'package:integration_test/integration_test.dart' ;
18
19
import 'package:flutter_test/flutter_test.dart' ;
@@ -71,12 +72,14 @@ void main() {
71
72
await Amplify .DataStore .save (testBlog);
72
73
73
74
var updatedBlog = testBlog.copyWith (name: 'changed name' );
74
- await Amplify .DataStore .save (updatedBlog,
75
- where: Blog .NAME .contains ("Predicate" ));
76
75
77
- var blogs = await Amplify .DataStore .query (Blog .classType);
78
- expect (blogs.length, 1 );
79
- expect (blogs[0 ].name, originalBlogName);
76
+ expect (
77
+ () => Amplify .DataStore .save (updatedBlog,
78
+ where: Blog .NAME .contains ("Predicate" )),
79
+ throwsA (predicate ((e) =>
80
+ e is DataStoreException &&
81
+ e.message.contains (
82
+ "condition did not match existing model instance" ))));
80
83
});
81
84
82
85
testWidgets ('predicate should not prevent save for matching model' ,
@@ -89,7 +92,7 @@ void main() {
89
92
const matchingBlogName = 'matching blog name' ;
90
93
var updatedBlog = testBlog.copyWith (name: matchingBlogName);
91
94
await Amplify .DataStore .save (updatedBlog,
92
- where: Blog .NAME .contains ("matching " ));
95
+ where: Blog .NAME .contains ("original " ));
93
96
94
97
var blogs = await Amplify .DataStore .query (Blog .classType);
95
98
expect (blogs.length, 1 );
0 commit comments