@@ -12,6 +12,14 @@ import 'package:integration_test/integration_test.dart';
12
12
13
13
import '../util.dart' ;
14
14
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
+
15
23
void main ({bool useExistingTestUser = false }) {
16
24
IntegrationTestWidgetsFlutterBinding .ensureInitialized ();
17
25
@@ -128,6 +136,7 @@ void main({bool useExistingTestUser = false}) {
128
136
final req = ModelQueries .list <Blog >(
129
137
Blog .classType,
130
138
where: Blog .NAME .eq (blogName) & Blog .ID .eq (blog.id),
139
+ limit: _limit,
131
140
);
132
141
final res = await Amplify .API .query (request: req).response;
133
142
final data = res.data;
@@ -145,8 +154,11 @@ void main({bool useExistingTestUser = false}) {
145
154
const rating = 0 ;
146
155
final createdPost = await addPostAndBlog (title, rating);
147
156
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
+ );
150
162
final res = await Amplify .API .query (request: req).response;
151
163
final postFromResponse = res.data? .items[0 ];
152
164
@@ -162,8 +174,11 @@ void main({bool useExistingTestUser = false}) {
162
174
final createdPost = await addPostAndBlog (title, rating);
163
175
final blogId = createdPost.blog? .id;
164
176
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
+ );
167
182
final res = await Amplify .API .query (request: req).response;
168
183
final postFromResponse = res.data? .items[0 ];
169
184
0 commit comments