|
|
@@ -30,7 +30,7 @@ class StatusCodeValidationTestCase: BaseTestCase {
|
|
|
let URLString = "https://httpbin.org/status/200"
|
|
|
let expectation = expectationWithDescription("request should return 200 status code")
|
|
|
|
|
|
- var error: NSError?
|
|
|
+ var error: ErrorType?
|
|
|
|
|
|
// When
|
|
|
Alamofire.request(.GET, URLString)
|
|
|
@@ -51,7 +51,7 @@ class StatusCodeValidationTestCase: BaseTestCase {
|
|
|
let URLString = "https://httpbin.org/status/404"
|
|
|
let expectation = expectationWithDescription("request should return 404 status code")
|
|
|
|
|
|
- var error: NSError?
|
|
|
+ var error: ErrorType?
|
|
|
|
|
|
// When
|
|
|
Alamofire.request(.GET, URLString)
|
|
|
@@ -66,9 +66,11 @@ class StatusCodeValidationTestCase: BaseTestCase {
|
|
|
// Then
|
|
|
XCTAssertNotNil(error, "error should not be nil")
|
|
|
|
|
|
- if let error = error {
|
|
|
+ if let error = error as? NSError {
|
|
|
XCTAssertEqual(error.domain, Error.Domain, "domain should be Alamofire error domain")
|
|
|
XCTAssertEqual(error.code, Error.Code.StatusCodeValidationFailed.rawValue, "code should be status code validation failure")
|
|
|
+ } else {
|
|
|
+ XCTFail("error should be an NSError")
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -77,7 +79,7 @@ class StatusCodeValidationTestCase: BaseTestCase {
|
|
|
let URLString = "https://httpbin.org/status/201"
|
|
|
let expectation = expectationWithDescription("request should return 201 status code")
|
|
|
|
|
|
- var error: NSError?
|
|
|
+ var error: ErrorType?
|
|
|
|
|
|
// When
|
|
|
Alamofire.request(.GET, URLString)
|
|
|
@@ -92,9 +94,11 @@ class StatusCodeValidationTestCase: BaseTestCase {
|
|
|
// Then
|
|
|
XCTAssertNotNil(error, "error should not be nil")
|
|
|
|
|
|
- if let error = error {
|
|
|
+ if let error = error as? NSError {
|
|
|
XCTAssertEqual(error.domain, Error.Domain, "domain should be Alamofire error domain")
|
|
|
XCTAssertEqual(error.code, Error.Code.StatusCodeValidationFailed.rawValue, "code should be status code validation failure")
|
|
|
+ } else {
|
|
|
+ XCTFail("error should be an NSError")
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -107,7 +111,7 @@ class ContentTypeValidationTestCase: BaseTestCase {
|
|
|
let URLString = "https://httpbin.org/ip"
|
|
|
let expectation = expectationWithDescription("request should succeed and return ip")
|
|
|
|
|
|
- var error: NSError?
|
|
|
+ var error: ErrorType?
|
|
|
|
|
|
// When
|
|
|
Alamofire.request(.GET, URLString)
|
|
|
@@ -128,7 +132,7 @@ class ContentTypeValidationTestCase: BaseTestCase {
|
|
|
let URLString = "https://httpbin.org/ip"
|
|
|
let expectation = expectationWithDescription("request should succeed and return ip")
|
|
|
|
|
|
- var error: NSError?
|
|
|
+ var error: ErrorType?
|
|
|
|
|
|
// When
|
|
|
Alamofire.request(.GET, URLString)
|
|
|
@@ -151,7 +155,7 @@ class ContentTypeValidationTestCase: BaseTestCase {
|
|
|
let URLString = "https://httpbin.org/xml"
|
|
|
let expectation = expectationWithDescription("request should succeed and return xml")
|
|
|
|
|
|
- var error: NSError?
|
|
|
+ var error: ErrorType?
|
|
|
|
|
|
// When
|
|
|
Alamofire.request(.GET, URLString)
|
|
|
@@ -166,9 +170,11 @@ class ContentTypeValidationTestCase: BaseTestCase {
|
|
|
// Then
|
|
|
XCTAssertNotNil(error, "error should not be nil")
|
|
|
|
|
|
- if let error = error {
|
|
|
+ if let error = error as? NSError {
|
|
|
XCTAssertEqual(error.domain, Error.Domain, "domain should be Alamofire error domain")
|
|
|
XCTAssertEqual(error.code, Error.Code.ContentTypeValidationFailed.rawValue, "code should be content type validation failure")
|
|
|
+ } else {
|
|
|
+ XCTFail("error should be an NSError")
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -177,7 +183,7 @@ class ContentTypeValidationTestCase: BaseTestCase {
|
|
|
let URLString = "https://httpbin.org/xml"
|
|
|
let expectation = expectationWithDescription("request should succeed and return xml")
|
|
|
|
|
|
- var error: NSError?
|
|
|
+ var error: ErrorType?
|
|
|
|
|
|
// When
|
|
|
Alamofire.request(.GET, URLString)
|
|
|
@@ -192,9 +198,11 @@ class ContentTypeValidationTestCase: BaseTestCase {
|
|
|
// Then
|
|
|
XCTAssertNotNil(error, "error should not be nil")
|
|
|
|
|
|
- if let error = error {
|
|
|
+ if let error = error as? NSError {
|
|
|
XCTAssertEqual(error.domain, Error.Domain, "domain should be Alamofire error domain")
|
|
|
XCTAssertEqual(error.code, Error.Code.ContentTypeValidationFailed.rawValue, "code should be content type validation failure")
|
|
|
+ } else {
|
|
|
+ XCTFail("error should be an NSError")
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -250,7 +258,7 @@ class ContentTypeValidationTestCase: BaseTestCase {
|
|
|
|
|
|
var response: NSHTTPURLResponse?
|
|
|
var data: NSData?
|
|
|
- var error: NSError?
|
|
|
+ var error: ErrorType?
|
|
|
|
|
|
// When
|
|
|
manager.request(.DELETE, URLString)
|
|
|
@@ -285,7 +293,7 @@ class MultipleValidationTestCase: BaseTestCase {
|
|
|
let URLString = "https://httpbin.org/ip"
|
|
|
let expectation = expectationWithDescription("request should succeed and return ip")
|
|
|
|
|
|
- var error: NSError?
|
|
|
+ var error: ErrorType?
|
|
|
|
|
|
// When
|
|
|
Alamofire.request(.GET, URLString)
|
|
|
@@ -307,7 +315,7 @@ class MultipleValidationTestCase: BaseTestCase {
|
|
|
let URLString = "https://httpbin.org/xml"
|
|
|
let expectation = expectationWithDescription("request should succeed and return xml")
|
|
|
|
|
|
- var error: NSError?
|
|
|
+ var error: ErrorType?
|
|
|
|
|
|
// When
|
|
|
Alamofire.request(.GET, URLString)
|
|
|
@@ -323,9 +331,11 @@ class MultipleValidationTestCase: BaseTestCase {
|
|
|
// Then
|
|
|
XCTAssertNotNil(error, "error should not be nil")
|
|
|
|
|
|
- if let error = error {
|
|
|
+ if let error = error as? NSError {
|
|
|
XCTAssertEqual(error.domain, Error.Domain, "domain should be Alamofire error domain")
|
|
|
XCTAssertEqual(error.code, Error.Code.StatusCodeValidationFailed.rawValue, "code should be status code validation failure")
|
|
|
+ } else {
|
|
|
+ XCTFail("error should be an NSError")
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -334,7 +344,7 @@ class MultipleValidationTestCase: BaseTestCase {
|
|
|
let URLString = "https://httpbin.org/xml"
|
|
|
let expectation = expectationWithDescription("request should succeed and return xml")
|
|
|
|
|
|
- var error: NSError?
|
|
|
+ var error: ErrorType?
|
|
|
|
|
|
// When
|
|
|
Alamofire.request(.GET, URLString)
|
|
|
@@ -350,9 +360,11 @@ class MultipleValidationTestCase: BaseTestCase {
|
|
|
// Then
|
|
|
XCTAssertNotNil(error, "error should not be nil")
|
|
|
|
|
|
- if let error = error {
|
|
|
+ if let error = error as? NSError {
|
|
|
XCTAssertEqual(error.domain, Error.Domain, "domain should be Alamofire error domain")
|
|
|
XCTAssertEqual(error.code, Error.Code.ContentTypeValidationFailed.rawValue, "code should be content type validation failure")
|
|
|
+ } else {
|
|
|
+ XCTFail("error should be an NSError")
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -368,7 +380,7 @@ class AutomaticValidationTestCase: BaseTestCase {
|
|
|
|
|
|
let expectation = expectationWithDescription("request should succeed and return ip")
|
|
|
|
|
|
- var error: NSError?
|
|
|
+ var error: ErrorType?
|
|
|
|
|
|
// When
|
|
|
Alamofire.request(mutableURLRequest)
|
|
|
@@ -389,7 +401,7 @@ class AutomaticValidationTestCase: BaseTestCase {
|
|
|
let URLString = "https://httpbin.org/status/404"
|
|
|
let expectation = expectationWithDescription("request should return 404 status code")
|
|
|
|
|
|
- var error: NSError?
|
|
|
+ var error: ErrorType?
|
|
|
|
|
|
// When
|
|
|
Alamofire.request(.GET, URLString)
|
|
|
@@ -404,9 +416,11 @@ class AutomaticValidationTestCase: BaseTestCase {
|
|
|
// Then
|
|
|
XCTAssertNotNil(error, "error should not be nil")
|
|
|
|
|
|
- if let error = error {
|
|
|
+ if let error = error as? NSError {
|
|
|
XCTAssertEqual(error.domain, Error.Domain, "domain should be Alamofire error domain")
|
|
|
XCTAssertEqual(error.code, Error.Code.StatusCodeValidationFailed.rawValue, "code should be status code validation failure")
|
|
|
+ } else {
|
|
|
+ XCTFail("error should be an NSError")
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -418,7 +432,7 @@ class AutomaticValidationTestCase: BaseTestCase {
|
|
|
|
|
|
let expectation = expectationWithDescription("request should succeed and return ip")
|
|
|
|
|
|
- var error: NSError?
|
|
|
+ var error: ErrorType?
|
|
|
|
|
|
// When
|
|
|
Alamofire.request(mutableURLRequest)
|
|
|
@@ -444,7 +458,7 @@ class AutomaticValidationTestCase: BaseTestCase {
|
|
|
|
|
|
let expectation = expectationWithDescription("request should succeed and return xml")
|
|
|
|
|
|
- var error: NSError?
|
|
|
+ var error: ErrorType?
|
|
|
|
|
|
// When
|
|
|
Alamofire.request(mutableURLRequest)
|
|
|
@@ -468,7 +482,7 @@ class AutomaticValidationTestCase: BaseTestCase {
|
|
|
|
|
|
let expectation = expectationWithDescription("request should succeed and return xml")
|
|
|
|
|
|
- var error: NSError?
|
|
|
+ var error: ErrorType?
|
|
|
|
|
|
// When
|
|
|
Alamofire.request(mutableURLRequest)
|
|
|
@@ -483,9 +497,11 @@ class AutomaticValidationTestCase: BaseTestCase {
|
|
|
// Then
|
|
|
XCTAssertNotNil(error, "error should not be nil")
|
|
|
|
|
|
- if let error = error {
|
|
|
+ if let error = error as? NSError {
|
|
|
XCTAssertEqual(error.domain, Error.Domain, "domain should be Alamofire error domain")
|
|
|
XCTAssertEqual(error.code, Error.Code.ContentTypeValidationFailed.rawValue, "code should be content type validation failure")
|
|
|
+ } else {
|
|
|
+ XCTFail("error should be an NSError")
|
|
|
}
|
|
|
}
|
|
|
}
|