Skip to content

Commit 0860430

Browse files
fix indentation, record value check
1 parent 646b6be commit 0860430

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

Sources/SnapshotTesting/AssertSnapshot.swift

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -273,23 +273,23 @@ public func verifySnapshot<Value, Format>(
273273

274274
let testName = sanitizePathComponent(testName)
275275

276-
// Check the bundle for the resource first, then the file system
277-
// But, if we're recording, don't bother checking the bundle, since we aren't comparing it to anything, and
278-
// want the new file to be generated in the source directory, not the bundle.
279-
var snapshotFileUrlCandidate: URL?
280-
if record != .never {
281-
let thisBundle = Bundle(for: CleanCounterBetweenTestCases.self)
282-
let resourcePath = thisBundle.path(forResource: "\(testName).\(identifier)", ofType: snapshotting.pathExtension)
283-
snapshotFileUrlCandidate = resourcePath.map({ URL(fileURLWithPath: $0) })
284-
}
285-
if snapshotFileUrlCandidate == nil {
286-
snapshotFileUrlCandidate = snapshotDirectoryUrl
287-
.appendingPathComponent("\(testName).\(identifier)")
288-
.appendingPathExtension(snapshotting.pathExtension ?? "")
289-
}
290-
guard let snapshotFileUrl = snapshotFileUrlCandidate else {
291-
return nil
292-
}
276+
// Check the bundle for the resource first, then the file system
277+
// But, if we're recording, don't bother checking the bundle, since we aren't comparing it to anything, and
278+
// want the new file to be generated in the source directory, not the bundle.
279+
var snapshotFileUrlCandidate: URL?
280+
if record != .all {
281+
let thisBundle = Bundle(for: CleanCounterBetweenTestCases.self)
282+
let resourcePath = thisBundle.path(forResource: "\(testName).\(identifier)", ofType: snapshotting.pathExtension)
283+
snapshotFileUrlCandidate = resourcePath.map({ URL(fileURLWithPath: $0) })
284+
}
285+
if snapshotFileUrlCandidate == nil {
286+
snapshotFileUrlCandidate = snapshotDirectoryUrl
287+
.appendingPathComponent("\(testName).\(identifier)")
288+
.appendingPathExtension(snapshotting.pathExtension ?? "")
289+
}
290+
guard let snapshotFileUrl = snapshotFileUrlCandidate else {
291+
return nil
292+
}
293293

294294
let fileManager = FileManager.default
295295
try fileManager.createDirectory(at: snapshotDirectoryUrl, withIntermediateDirectories: true)

0 commit comments

Comments
 (0)