Skip to content

Commit

Permalink
tear down test
Browse files Browse the repository at this point in the history
  • Loading branch information
vahidlazio committed Apr 10, 2024
1 parent 072708a commit 8951fe5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 2 additions & 3 deletions Sources/Confidence/EventStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ internal class EventStorageImpl: EventStorage {

init() throws {
self.folderURL = try EventStorageImpl.getFolderURL()
try FileManager.default.removeItem(at: folderURL)
if(!FileManager.default.fileExists(atPath: folderURL.backport.path)) {
try FileManager.default.createDirectory(at: folderURL, withIntermediateDirectories: true)
}
Expand Down Expand Up @@ -94,14 +93,14 @@ internal class EventStorageImpl: EventStorage {
self.currentFileUrl = currentFile
self.currentFileHandle = try FileHandle(forWritingTo: currentFile)
} else {
let fileUrl = folderURL.appendingPathComponent(Date().currentTime)
let fileUrl = folderURL.appendingPathComponent(String(Date().timeIntervalSince1970))
FileManager.default.createFile(atPath: fileUrl.path, contents: nil)
self.currentFileUrl = fileUrl
self.currentFileHandle = try FileHandle(forWritingTo: fileUrl)
}
}

private static func getFolderURL() throws -> URL {
internal static func getFolderURL() throws -> URL {
guard
let applicationSupportUrl: URL = FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask)
.last
Expand Down
7 changes: 7 additions & 0 deletions Tests/ConfidenceTests/EventStorageTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ class EventStorageTest: XCTestCase {
func testRemoveFile() {

}

override func setUp() {
let folderURL = try! EventStorageImpl.getFolderURL()
if FileManager.default.fileExists(atPath: folderURL.path) {
try! FileManager.default.removeItem(at: folderURL)
}
}
}


Expand Down

0 comments on commit 8951fe5

Please sign in to comment.