Skip to content

Instantly share code, notes, and snippets.

@akshitzaveri
Created April 23, 2020 18:36
Show Gist options
  • Save akshitzaveri/0832ce1277081a896a9cc2a6e4b8190f to your computer and use it in GitHub Desktop.
Save akshitzaveri/0832ce1277081a896a9cc2a6e4b8190f to your computer and use it in GitHub Desktop.
import XCTest
import Firebase
extension XCTestCase {
func clearFirestore() {
let semaphore = DispatchSemaphore(value: 0)
let projectId = FirebaseApp.app()!.options.projectID!
let url = URL(string: "http://localhost:8080/emulator/v1/projects/\(projectId)/databases/(default)/documents")!
var request = URLRequest(url: url)
request.httpMethod = "DELETE"
let task = URLSession.shared.dataTask(with: request) { _,_,_ in
print("Firestore cleared")
semaphore.signal()
}
task.resume()
semaphore.wait()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment