Created
April 23, 2020 18:36
-
-
Save akshitzaveri/0832ce1277081a896a9cc2a6e4b8190f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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