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

fix(samples): close firestore instance in test #476

Merged
merged 1 commit into from Feb 11, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -205,5 +205,11 @@ public static void main(String[] args) throws Exception {
String projectId = (args.length == 0) ? null : args[0];
Quickstart quickStart = (projectId != null) ? new Quickstart(projectId) : new Quickstart();
quickStart.run();
quickStart.close();
}

/** Closes the gRPC channels associated with this instance and frees up their resources. */
void close() throws Exception {
db.close();
}
}
Expand Up @@ -222,4 +222,8 @@ public void onEvent(@Nullable QuerySnapshot snapshots,
// [END listen_errors]
}

/** Closes the gRPC channels associated with this instance and frees up their resources. */
void close() throws Exception {
db.close();
}
}
Expand Up @@ -469,4 +469,8 @@ public void updateDocumentIncrement() throws ExecutionException, InterruptedExce
updateFuture.get();
}

/** Closes the gRPC channels associated with this instance and frees up their resources. */
void close() throws Exception {
db.close();
}
}
Expand Up @@ -644,4 +644,9 @@ Query filterNotIn() {
// [END fs_filter_not_in]
return query;
}

/** Closes the gRPC channels associated with this instance and frees up their resources. */
void close() throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to be overridden? It seems like the method in BaseIntegrationTest does the right thing already.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes,because QueryDataSnippets class also have instance variable with name db of type Firestore means BaseIntegrationTest have different instance while QueryDataSnippets class have a different instance of Firestore.

db.close();
}
}
Expand Up @@ -171,4 +171,9 @@ public Iterable<CollectionReference> listCollections() throws Exception {
// [END fs_get_collections]
return collections;
}

/** Closes the gRPC channels associated with this instance and frees up their resources. */
void close() throws Exception {
db.close();
}
}
Expand Up @@ -28,6 +28,7 @@
import com.google.cloud.firestore.FirestoreOptions;
import com.google.cloud.firestore.QuerySnapshot;
import java.util.Map;
import org.junit.AfterClass;
import org.junit.BeforeClass;

/**
Expand Down Expand Up @@ -83,4 +84,8 @@ protected static void deleteAllDocuments(Firestore db) throws Exception {
}
}

@AfterClass
public static void tearDownAfterClass() throws Exception {
db.close();
}
}
Expand Up @@ -113,5 +113,6 @@ private void deleteAllDocuments() throws Exception {
@After
public void tearDown() throws Exception {
deleteAllDocuments();
quickstart.close();
}
}
Expand Up @@ -75,5 +75,6 @@ public void testListenForChanges() throws Exception {
@AfterClass
public static void tearDown() throws Exception {
deleteAllDocuments(db);
listenDataSnippets.close();
}
}
Expand Up @@ -202,5 +202,6 @@ public void testUpdateDocumentIncrementSuccessful() throws Exception {
public static void tearDown() throws Exception {
manageDataSnippets.deleteCollection(db.collection("cities"), 10);
manageDataSnippets.deleteCollection(db.collection("users"), 10);
manageDataSnippets.close();
}
}
Expand Up @@ -284,5 +284,6 @@ private List<String> getResults(Query query) throws Exception {
@AfterClass
public static void tearDown() throws Exception {
deleteAllDocuments(db);
queryDataSnippets.close();
}
}
Expand Up @@ -126,5 +126,6 @@ private static void deleteAllDocuments() throws Exception {
@AfterClass
public static void tearDownAfterClass() throws Exception {
deleteAllDocuments();
retrieveDataSnippets.close();
}
}