Skip to content

Firestore: Add @CanIgnoreReturnValue annotations in tests #3872

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

Merged
merged 1 commit into from
Jul 6, 2022
Merged
Show file tree
Hide file tree
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 @@ -29,6 +29,7 @@
import com.google.android.gms.tasks.Task;
import com.google.android.gms.tasks.TaskCompletionSource;
import com.google.android.gms.tasks.Tasks;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.firebase.firestore.FirebaseFirestoreException.Code;
import com.google.firebase.firestore.testutil.IntegrationTestUtil;
import com.google.firebase.firestore.util.AsyncQueue.TimerId;
Expand Down Expand Up @@ -88,16 +89,19 @@ private static class TransactionTester {
db = inputDb;
}

@CanIgnoreReturnValue
public TransactionTester withExistingDoc() {
fromExistingDoc = true;
return this;
}

@CanIgnoreReturnValue
public TransactionTester withNonexistentDoc() {
fromExistingDoc = false;
return this;
}

@CanIgnoreReturnValue
public TransactionTester run(TransactionStage... inputStages) {
stages = Arrays.asList(inputStages);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.firebase.Timestamp;
import com.google.firebase.firestore.bundle.BundledQuery;
import com.google.firebase.firestore.core.Query;
Expand Down Expand Up @@ -81,6 +82,7 @@ static class TestWriteBuilder {
this.builder = Write.newBuilder();
}

@CanIgnoreReturnValue
TestWriteBuilder addSet() {
builder.setUpdate(
com.google.firestore.v1.Document.newBuilder()
Expand All @@ -90,6 +92,7 @@ TestWriteBuilder addSet() {
return this;
}

@CanIgnoreReturnValue
TestWriteBuilder addPatch() {
builder
.setUpdate(
Expand All @@ -102,11 +105,13 @@ TestWriteBuilder addPatch() {
return this;
}

@CanIgnoreReturnValue
TestWriteBuilder addDelete() {
builder.setDelete("projects/p/databases/d/documents/baz/quux");
return this;
}

@CanIgnoreReturnValue
TestWriteBuilder addUpdateTransforms() {
builder
.addUpdateTransforms(
Expand All @@ -120,6 +125,7 @@ TestWriteBuilder addUpdateTransforms() {
return this;
}

@CanIgnoreReturnValue
TestWriteBuilder addLegacyTransform() {
builder
.setTransform(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.google.common.primitives.Ints;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.firebase.firestore.util.Preconditions;
import java.util.Comparator;
import java.util.List;
Expand Down Expand Up @@ -101,6 +102,7 @@ public ComparatorTester(@Nullable Comparator<?> comparator) {
* Activates enforcement of {@code a.equals(b) == (a.compareTo(b) == 0)}. This is off by default
* when testing {@link Comparator}s, but can be turned on if required.
*/
@CanIgnoreReturnValue
public ComparatorTester requireConsistencyWithEquals() {
testForEqualsCompatibility = true;
return this;
Expand All @@ -110,6 +112,7 @@ public ComparatorTester requireConsistencyWithEquals() {
* Deactivates enforcement of {@code a.equals(b) == (a.compareTo(b) == 0)}. This is on by default
* when testing {@link Comparable}s, but can be turned off if required.
*/
@CanIgnoreReturnValue
public ComparatorTester permitInconsistencyWithEquals() {
testForEqualsCompatibility = false;
return this;
Expand All @@ -122,6 +125,7 @@ public ComparatorTester permitInconsistencyWithEquals() {
*
* @return {@code this} (to allow chaining of calls)
*/
@CanIgnoreReturnValue
public ComparatorTester addEqualityGroup(Object... objects) {
Preconditions.checkNotNull(objects);
Preconditions.checkArgument(objects.length > 0, "Array must not be empty");
Expand Down