Browse Source

Cleanup some old tests, run whitespace cleanup.

Jon Shier 8 years ago
parent
commit
888f93f86e

+ 1 - 1
Source/SessionManager.swift

@@ -70,7 +70,7 @@ open class SessionManager {
             return "\(languageCode);q=\(quality)"
         }.joined(separator: ", ")
         #endif
-        
+
         // User-Agent Header; see https://tools.ietf.org/html/rfc7231#section-5.5.3
         // Example: `iOS Example/1.0 (org.alamofire.iOS-Example; build:1; iOS 10.0.0) Alamofire/4.0.0`
         let userAgent: String = {

+ 7 - 7
Tests/ResponseTests.swift

@@ -272,13 +272,13 @@ class ResponseJSONTestCase: BaseTestCase {
         XCTAssertNotNil(response?.data)
         XCTAssertEqual(response?.result.isSuccess, true)
 
-        if #available(iOS 10.0, macOS 10.12, tvOS 10.0, *) {
+        if #available(iOS 10.0, macOS 10.12, tvOS 10.0, watchOS 3.0, *) {
             XCTAssertNotNil(response?.metrics)
         }
 
-        // The `as NSString` cast is necessary due to a compiler bug. See the following rdar for more info.
-        // - https://openradar.appspot.com/radar?id=5517037090635776
-        if let args = (response?.result.value as AnyObject?)?["args" as NSString] as? [String: String] {
+        if
+            let responseDictionary = response?.result.value as? [String : Any],
+            let args = responseDictionary["args"] as? [String : String] {
             XCTAssertEqual(args, ["foo": "bar"], "args should match parameters")
         } else {
             XCTFail("args should not be nil")
@@ -311,9 +311,9 @@ class ResponseJSONTestCase: BaseTestCase {
             XCTAssertNotNil(response?.metrics)
         }
 
-        // The `as NSString` cast is necessary due to a compiler bug. See the following rdar for more info.
-        // - https://openradar.appspot.com/radar?id=5517037090635776
-        if let form = (response?.result.value as AnyObject?)?["form" as NSString] as? [String: String] {
+        if
+            let responseDictionary = response?.result.value as? [String : Any],
+            let form = responseDictionary["form"] as? [String : String] {
             XCTAssertEqual(form, ["foo": "bar"], "form should match parameters")
         } else {
             XCTFail("form should not be nil")

+ 2 - 3
Tests/SessionManagerTests.swift

@@ -840,10 +840,9 @@ class SessionManagerConfigurationHeadersTestCase: BaseTestCase {
             XCTAssertNotNil(response.data, "data should not be nil")
             XCTAssertTrue(response.result.isSuccess, "result should be a success")
 
-            // The `as NSString` cast is necessary due to a compiler bug. See the following rdar for more info.
-            // - https://openradar.appspot.com/radar?id=5517037090635776
             if
-                let headers = (response.result.value as AnyObject?)?["headers" as NSString] as? [String: String],
+                let response = response.result.value as? [String : Any],
+                let headers = response["headers"] as? [String: String],
                 let authorization = headers["Authorization"]
             {
                 XCTAssertEqual(authorization, "Bearer 123456", "authorization header value does not match")

+ 3 - 3
Tests/URLProtocolTests.swift

@@ -95,16 +95,16 @@ class ProxyURLProtocol: URLProtocol {
 extension ProxyURLProtocol: URLSessionDataDelegate {
 
     // MARK: NSURLSessionDelegate
-    
+
     func urlSession(_ session: URLSession, dataTask: URLSessionDataTask, didReceive data: Data) {
         client?.urlProtocol(self, didLoad: data)
     }
-    
+
     func urlSession(_ session: URLSession, task: URLSessionTask, didCompleteWithError error: Error?) {
         if let response = task.response {
             client?.urlProtocol(self, didReceive: response, cacheStoragePolicy: .notAllowed)
         }
-        
+
         client?.urlProtocolDidFinishLoading(self)
     }
 }

+ 4 - 4
Tests/UploadTests.swift

@@ -532,7 +532,7 @@ class UploadMultipartFormDataTestCase: BaseTestCase {
             XCTFail("Content-Type header value should not be nil")
         }
     }
-    
+
     #if os(macOS)
     func testThatUploadingMultipartFormDataOnBackgroundSessionWritesDataToFileToAvoidCrash() {
         // Given
@@ -564,20 +564,20 @@ class UploadMultipartFormDataTestCase: BaseTestCase {
             switch result {
             case let .success(upload, uploadStreamingFromDisk, _):
                 streamingFromDisk = uploadStreamingFromDisk
-                
+
                 upload.response { defaultResponse in
                     request = defaultResponse.request
                     response = defaultResponse.response
                     data = defaultResponse.data
                     error = defaultResponse.error
-                    
+
                     expectation.fulfill()
                 }
             case .failure:
                 expectation.fulfill()
             }
         })
-        
+
         waitForExpectations(timeout: timeout, handler: nil)
 
         // Then