From 79a2a196623888041bc0967d4453da816c834ced Mon Sep 17 00:00:00 2001 From: Jordan Nelson Date: Fri, 27 Oct 2023 13:53:19 -0400 Subject: [PATCH] chore: fix flaky api e2e test (#4017) * chore: force api tests to run * chore: add limit * chore: update limit * chore: add limit to other tests --- .../integration_test/graphql/iam_test.dart | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/packages/api/amplify_api/example/integration_test/graphql/iam_test.dart b/packages/api/amplify_api/example/integration_test/graphql/iam_test.dart index ff2dc8313b..f7f20df403 100644 --- a/packages/api/amplify_api/example/integration_test/graphql/iam_test.dart +++ b/packages/api/amplify_api/example/integration_test/graphql/iam_test.dart @@ -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(); @@ -128,6 +136,7 @@ void main({bool useExistingTestUser = false}) { final req = ModelQueries.list( 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; @@ -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]; @@ -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];