File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change 1
1
import Quick
2
2
import Nimble
3
+ import CryptoSwift
3
4
@testable import Cache
4
5
5
6
class DiskStorageSpec : QuickSpec {
@@ -178,7 +179,19 @@ class DiskStorageSpec: QuickSpec {
178
179
179
180
describe ( " #fileName " ) {
180
181
it ( " returns a correct file name " ) {
181
- expect ( storage. fileName ( key) ) . to ( equal ( key. base64 ( ) ) )
182
+ if let digest = key. dataUsingEncoding ( NSUTF8StringEncoding) ? . md5 ( ) {
183
+ var string = " "
184
+ var byte : UInt8 = 0
185
+
186
+ for i in 0 ..< digest. length {
187
+ digest. getBytes ( & byte, range: NSMakeRange ( i, 1 ) )
188
+ string += String ( format: " %02x " , byte)
189
+ }
190
+
191
+ expect ( storage. fileName ( key) ) . to ( equal ( string) )
192
+ } else {
193
+ expect ( storage. fileName ( key) ) . to ( equal ( key. base64 ( ) ) )
194
+ }
182
195
}
183
196
}
184
197
You can’t perform that action at this time.
0 commit comments