Skip to content

Commit

Permalink
Update test cases to make them pass when useURLsession is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
crazytonyli committed Feb 5, 2024
1 parent 2f993dd commit 962d56d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion WordPressKitTests/WordPressOrgXMLRPCApiTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,16 @@ class WordPressOrgXMLRPCApiTests: XCTestCase {
XCTAssertEqual(error.domain, WPXMLRPCFaultErrorDomain)
// 403 is the 'faultCode' in the HTTP response xml.
XCTAssertEqual(error.code, 403)
XCTAssertNil(error.userInfo[WordPressOrgXMLRPCApi.WordPressOrgXMLRPCApiErrorKeyData as String])
XCTAssertNil(error.userInfo[WordPressOrgXMLRPCApi.WordPressOrgXMLRPCApiErrorKeyStatusCode as String])

// The change highlights one difference between the existing Alamofire-backed API and the new
// URLSession-backed API: the error returned by the new one may has HTTP response body which may not
// be the case exist in the old API. I think this is an acceptable change.
if WordPressOrgXMLRPCApi.useURLSession {
XCTAssertNotNil(error.userInfo[WordPressOrgXMLRPCApi.WordPressOrgXMLRPCApiErrorKeyData as String])
} else {
XCTAssertNil(error.userInfo[WordPressOrgXMLRPCApi.WordPressOrgXMLRPCApiErrorKeyData as String])
}
}
)
wait(for: [expect], timeout: 0.3)
Expand Down

0 comments on commit 962d56d

Please sign in to comment.