Skip to content

Commit 1702d9d

Browse files
committed
fix(test): rename variables to avoid naming collision with responseString
1 parent f880cae commit 1702d9d

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

Tests/SwiftApiAdapterTests/ApiConnectorManagerTests.swift

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,14 @@ class ApiSerialExecutorTests: XCTestCase {
4949
let method = "GET"
5050
let headers = ["Content-Type": "application/json; charset=UTF-8"]
5151

52-
let responseString = await executor.executeJsonApiImmediately(Data(), endpoint: endpoint, method: method, headers: headers)
52+
let apiResponse = await executor.executeJsonApiImmediately(Data(), endpoint: endpoint, method: method, headers: headers)
53+
54+
XCTAssertNotNil(apiResponse)
55+
56+
if let apiResponse = apiResponse, let jsonString = apiResponse.responseString {
57+
let jsonData = jsonString.data(using: .utf8)!
58+
let json = try JSON(data: jsonData)
5359

54-
XCTAssertNotNil(responseString)
55-
if let responseString = responseString {
56-
let json = try JSON(data: responseString.data(using: .utf8)!)
5760
XCTAssertEqual(json["title"].string, "sunt aut facere repellat provident occaecati excepturi optio reprehenderit")
5861
XCTAssertEqual(json["body"].string, "quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto")
5962
XCTAssertEqual(json["userId"].int, 1)

Tests/SwiftApiAdapterTests/ApiRequesterTests.swift

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,19 @@ class ApiRequesterTests: XCTestCase {
1414
let headers = ["Content-Type": "application/json; charset=UTF-8"]
1515
let body = "" // GET request typically does not have a body
1616

17-
let responseString = await requester.processJsonApi(endpoint: endpoint, method: method, headers: headers, body: body, immediate: true)
17+
let apiResponse = await requester.processJsonApi(
18+
endpoint: endpoint,
19+
method: method,
20+
headers: headers,
21+
body: body,
22+
immediate: true
23+
)
24+
25+
XCTAssertNotNil(apiResponse)
26+
if let apiResponse = apiResponse, let jsonString = apiResponse.responseString {
27+
let jsonData = jsonString.data(using: .utf8)!
28+
let json = try JSON(data: jsonData)
1829

19-
XCTAssertNotNil(responseString)
20-
if let responseString = responseString {
21-
let json = try JSON(data: responseString.data(using: .utf8)!)
2230
XCTAssertEqual(json["title"].string, "sunt aut facere repellat provident occaecati excepturi optio reprehenderit")
2331
XCTAssertEqual(json["body"].string, "quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto")
2432
XCTAssertEqual(json["userId"].int, 1)

0 commit comments

Comments
 (0)