@@ -12,6 +12,14 @@ import 'package:integration_test/integration_test.dart';
1212
1313import '../util.dart' ;
1414
15+ /// A limit to use in [ModelQueries.list] operations.
16+ ///
17+ /// Tests that use [ModelQueries.list] and expect certain models in the response
18+ /// can fail if the DB has a large number of items in it. Models are cleaned up
19+ /// after tests complete, but during test execution the number of models can
20+ /// increase past the default limit.
21+ const _limit = 10000 ;
22+
1523void main ({bool useExistingTestUser = false }) {
1624 IntegrationTestWidgetsFlutterBinding .ensureInitialized ();
1725
@@ -128,6 +136,7 @@ void main({bool useExistingTestUser = false}) {
128136 final req = ModelQueries .list <Blog >(
129137 Blog .classType,
130138 where: Blog .NAME .eq (blogName) & Blog .ID .eq (blog.id),
139+ limit: _limit,
131140 );
132141 final res = await Amplify .API .query (request: req).response;
133142 final data = res.data;
@@ -145,8 +154,11 @@ void main({bool useExistingTestUser = false}) {
145154 const rating = 0 ;
146155 final createdPost = await addPostAndBlog (title, rating);
147156
148- final req =
149- ModelQueries .list (Post .classType, where: Post .TITLE .eq (title));
157+ final req = ModelQueries .list (
158+ Post .classType,
159+ where: Post .TITLE .eq (title),
160+ limit: _limit,
161+ );
150162 final res = await Amplify .API .query (request: req).response;
151163 final postFromResponse = res.data? .items[0 ];
152164
@@ -162,8 +174,11 @@ void main({bool useExistingTestUser = false}) {
162174 final createdPost = await addPostAndBlog (title, rating);
163175 final blogId = createdPost.blog? .id;
164176
165- final req =
166- ModelQueries .list (Post .classType, where: Post .BLOG .eq (blogId));
177+ final req = ModelQueries .list (
178+ Post .classType,
179+ where: Post .BLOG .eq (blogId),
180+ limit: _limit,
181+ );
167182 final res = await Amplify .API .query (request: req).response;
168183 final postFromResponse = res.data? .items[0 ];
169184
0 commit comments