Skip to content

Commit

Permalink
fix(samples): close firestore instance in test (#476)
Browse files Browse the repository at this point in the history
  • Loading branch information
suraj-qlogic committed Feb 11, 2021
1 parent 69a53ce commit fb1cb17
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 0 deletions.
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 {
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();
}
}

0 comments on commit fb1cb17

Please sign in to comment.