Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fix flaky api e2e test #4017

Merged
merged 4 commits into from
Oct 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading