Skip to content

Commit

Permalink
fix(post-generator): make id increment consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
JoachimFavre committed May 25, 2024
1 parent 313903e commit da0f60b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions test/mocks/data/firestore_post.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ import "post_data.dart";
class FirestorePostGenerator {
int _postId = 0;

int _nextPostId() {
return _postId++;
}

/// Create a [PostFirestore] with given data
PostFirestore createPostAt(
PostData data,
Expand All @@ -23,7 +27,7 @@ class FirestorePostGenerator {
}) {
final point = GeoFirePoint(location);

id ??= (_postId++).toString();
id ??= _nextPostId().toString();

return PostFirestore(
id: PostIdFirestore(value: id),
Expand Down Expand Up @@ -65,11 +69,9 @@ class FirestorePostGenerator {
) {
final point = GeoFirePoint(location);

_postId += 1;

return PostFirestore(
id: PostIdFirestore(
value: _postId.toString(),
value: _nextPostId().toString(),
),
location: PostLocationFirestore(
geoPoint: location,
Expand Down

0 comments on commit da0f60b

Please sign in to comment.