Browse Source

Refactored suggestedDownloadDestination API to match FileManager APIs.

Christian Noon 9 years ago
parent
commit
3d23fd8213
3 changed files with 7 additions and 11 deletions
  1. 2 2
      Source/Request.swift
  2. 4 8
      Tests/DownloadTests.swift
  3. 1 1
      Tests/ServerTrustPolicyTests.swift

+ 2 - 2
Source/Request.swift

@@ -227,8 +227,8 @@ public class Request {
     ///
     /// - returns: A download file destination closure.
     public class func suggestedDownloadDestination(
-        directory: FileManager.SearchPathDirectory = .documentDirectory,
-        domain: FileManager.SearchPathDomainMask = .userDomainMask)
+        for directory: FileManager.SearchPathDirectory = .documentDirectory,
+        in domain: FileManager.SearchPathDomainMask = .userDomainMask)
         -> DownloadFileDestination
     {
         return { temporaryURL, response -> URL in

+ 4 - 8
Tests/DownloadTests.swift

@@ -33,7 +33,7 @@ class DownloadInitializationTestCase: BaseTestCase {
     func testDownloadClassMethodWithMethodURLAndDestination() {
         // Given
         let urlString = "https://httpbin.org/"
-        let destination = Request.suggestedDownloadDestination(directory: searchPathDirectory, domain: searchPathDomain)
+        let destination = Request.suggestedDownloadDestination(for: searchPathDirectory, in: searchPathDomain)
 
         // When
         let request = Alamofire.download(urlString, to: destination, withMethod: .get)
@@ -49,7 +49,7 @@ class DownloadInitializationTestCase: BaseTestCase {
         // Given
         let urlString = "https://httpbin.org/"
         let headers = ["Authorization": "123456"]
-        let destination = Request.suggestedDownloadDestination(directory: searchPathDirectory, domain: searchPathDomain)
+        let destination = Request.suggestedDownloadDestination(for: searchPathDirectory, in: searchPathDomain)
 
         // When
         let request = Alamofire.download(urlString, to: destination, withMethod: .get, headers: headers)
@@ -87,11 +87,7 @@ class DownloadResponseTestCase: BaseTestCase {
         // Given
         let numberOfLines = 100
         let urlString = "https://httpbin.org/stream/\(numberOfLines)"
-
-        let destination = Alamofire.Request.suggestedDownloadDestination(
-            directory: searchPathDirectory,
-            domain: searchPathDomain
-        )
+        let destination = Alamofire.Request.suggestedDownloadDestination(for: searchPathDirectory, in: searchPathDomain)
 
         let expectation = self.expectation(description: "Download request should download data to file: \(urlString)")
 
@@ -345,7 +341,7 @@ class DownloadResumeDataTestCase: BaseTestCase {
         let searchPathDirectory: FileManager.SearchPathDirectory = .cachesDirectory
         let searchPathDomain: FileManager.SearchPathDomainMask = .userDomainMask
 
-        return Request.suggestedDownloadDestination(directory: searchPathDirectory, domain: searchPathDomain)
+        return Request.suggestedDownloadDestination(for: searchPathDirectory, in: searchPathDomain)
     }()
 
     func testThatImmediatelyCancelledDownloadDoesNotHaveResumeDataAvailable() {

+ 1 - 1
Tests/ServerTrustPolicyTests.swift

@@ -1404,7 +1404,7 @@ class ServerTrustPolicyCertificatesInBundleTestCase: ServerTrustPolicyTestCase {
 
         // When
         let certificates = ServerTrustPolicy.certificates(
-            within: Bundle(for: ServerTrustPolicyCertificatesInBundleTestCase.self)
+            in: Bundle(for: ServerTrustPolicyCertificatesInBundleTestCase.self)
         )
 
         // Then