Skip to content

Commit 7e3a916

Browse files
authored
Merge pull request #148 from rvanmil/master
fixes #147
2 parents 0d7d800 + 29b9aca commit 7e3a916

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

Source/Shared/Storage/DiskStorage.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ extension DiskStorage: StorageAware {
8080

8181
func removeAll() throws {
8282
try fileManager.removeItem(atPath: path)
83+
try createDirectory()
8384
}
8485

8586
func removeExpiredObjects() throws {

Tests/iOS/Tests/Storage/DiskStorageTests.swift

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,20 +145,24 @@ final class DiskStorageTests: XCTestCase {
145145
}
146146
}
147147

148-
then("the folder should be deleted") {
148+
then("the folder should exist") {
149149
let fileExist = fileManager.fileExists(atPath: storage.path)
150-
XCTAssertFalse(fileExist)
150+
XCTAssertTrue(fileExist)
151151
}
152-
}
152+
153+
then("the folder should be empty") {
154+
let contents = try? fileManager.contentsOfDirectory(atPath: storage.path)
155+
XCTAssertEqual(contents?.count, 0)
156+
}
157+
}
153158

154159
/// Test that it clears cache files, but keeps root directory
155160
func testCreateDirectory() {
156161
do {
157162
try storage.removeAll()
158-
XCTAssertFalse(fileManager.fileExists(atPath: storage.path))
159-
160-
try storage.createDirectory()
161163
XCTAssertTrue(fileManager.fileExists(atPath: storage.path))
164+
let contents = try? fileManager.contentsOfDirectory(atPath: storage.path)
165+
XCTAssertEqual(contents?.count, 0)
162166
} catch {
163167
XCTFail(error.localizedDescription)
164168
}

Tests/iOS/Tests/Storage/HybridStorageTests.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,9 @@ final class HybridStorageTests: XCTestCase {
110110
try storage.setObject(testObject, forKey: key)
111111
try storage.removeAll()
112112

113-
then("the disk directory is removed") {
114-
XCTAssertFalse(fileManager.fileExists(atPath: storage.diskStorage.path))
113+
then("the disk directory is empty") {
114+
let contents = try? fileManager.contentsOfDirectory(atPath: storage.diskStorage.path)
115+
XCTAssertEqual(contents?.count, 0)
115116
}
116117
}
117118

0 commit comments

Comments
 (0)