File tree Expand file tree Collapse file tree 3 files changed +14
-8
lines changed Expand file tree Collapse file tree 3 files changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -80,6 +80,7 @@ extension DiskStorage: StorageAware {
80
80
81
81
func removeAll( ) throws {
82
82
try fileManager. removeItem ( atPath: path)
83
+ try createDirectory ( )
83
84
}
84
85
85
86
func removeExpiredObjects( ) throws {
Original file line number Diff line number Diff line change @@ -145,20 +145,24 @@ final class DiskStorageTests: XCTestCase {
145
145
}
146
146
}
147
147
148
- then ( " the folder should be deleted " ) {
148
+ then ( " the folder should exist " ) {
149
149
let fileExist = fileManager. fileExists ( atPath: storage. path)
150
- XCTAssertFalse ( fileExist)
150
+ XCTAssertTrue ( fileExist)
151
151
}
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
+ }
153
158
154
159
/// Test that it clears cache files, but keeps root directory
155
160
func testCreateDirectory( ) {
156
161
do {
157
162
try storage. removeAll ( )
158
- XCTAssertFalse ( fileManager. fileExists ( atPath: storage. path) )
159
-
160
- try storage. createDirectory ( )
161
163
XCTAssertTrue ( fileManager. fileExists ( atPath: storage. path) )
164
+ let contents = try ? fileManager. contentsOfDirectory ( atPath: storage. path)
165
+ XCTAssertEqual ( contents? . count, 0 )
162
166
} catch {
163
167
XCTFail ( error. localizedDescription)
164
168
}
Original file line number Diff line number Diff line change @@ -110,8 +110,9 @@ final class HybridStorageTests: XCTestCase {
110
110
try storage. setObject ( testObject, forKey: key)
111
111
try storage. removeAll ( )
112
112
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 )
115
116
}
116
117
}
117
118
You can’t perform that action at this time.
0 commit comments