Skip to content

Commit

Permalink
chore: fix flaky api e2e test (#4017)
Browse files Browse the repository at this point in the history
* chore: force api tests to run

* chore: add limit

* chore: update limit

* chore: add limit to other tests
  • Loading branch information
Jordan-Nelson authored Oct 27, 2023
1 parent 96fb7ce commit a84d78e
Showing 1 changed file with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ import 'package:integration_test/integration_test.dart';

import '../util.dart';

/// A limit to use in [ModelQueries.list] operations.
///
/// Tests that use [ModelQueries.list] and expect certain models in the response
/// can fail if the DB has a large number of items in it. Models are cleaned up
/// after tests complete, but during test execution the number of models can
/// increase past the default limit.
const _limit = 10000;

void main({bool useExistingTestUser = false}) {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();

Expand Down Expand Up @@ -128,6 +136,7 @@ void main({bool useExistingTestUser = false}) {
final req = ModelQueries.list<Blog>(
Blog.classType,
where: Blog.NAME.eq(blogName) & Blog.ID.eq(blog.id),
limit: _limit,
);
final res = await Amplify.API.query(request: req).response;
final data = res.data;
Expand All @@ -145,8 +154,11 @@ void main({bool useExistingTestUser = false}) {
const rating = 0;
final createdPost = await addPostAndBlog(title, rating);

final req =
ModelQueries.list(Post.classType, where: Post.TITLE.eq(title));
final req = ModelQueries.list(
Post.classType,
where: Post.TITLE.eq(title),
limit: _limit,
);
final res = await Amplify.API.query(request: req).response;
final postFromResponse = res.data?.items[0];

Expand All @@ -162,8 +174,11 @@ void main({bool useExistingTestUser = false}) {
final createdPost = await addPostAndBlog(title, rating);
final blogId = createdPost.blog?.id;

final req =
ModelQueries.list(Post.classType, where: Post.BLOG.eq(blogId));
final req = ModelQueries.list(
Post.classType,
where: Post.BLOG.eq(blogId),
limit: _limit,
);
final res = await Amplify.API.query(request: req).response;
final postFromResponse = res.data?.items[0];

Expand Down

0 comments on commit a84d78e

Please sign in to comment.