Skip to content

Commit aa8faa7

Browse files
committed
Update iOSReleaseTestTests.swift
1 parent 44f17bc commit aa8faa7

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

SDKIntegrationTestApps/iOSReleaseTest-SPM/iOSReleaseTestTests/iOSReleaseTestTests.swift

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import XCTest
99
@testable import iOSReleaseTest
10+
import BranchSDK
1011

1112
final class iOSReleaseTestTests: XCTestCase {
1213

@@ -21,6 +22,47 @@ final class iOSReleaseTestTests: XCTestCase {
2122

2223
print("[TestSetup] Test observer registered for enhanced GitHub Actions logging")
2324

25+
Branch.setCallbackForTracingRequests { url, request, response, error, serviceURL in
26+
// traceQueue.async {
27+
print("Tracing Callback Start ********************");
28+
print("URL: " + (url ?? ""));
29+
if let dict = request as? [AnyHashable: Any] {
30+
let stringDict = dict.reduce(into: [String: Any]()) { result, entry in
31+
if let key = entry.key as? String {
32+
result[key] = entry.value
33+
}
34+
}
35+
36+
if let data = try? JSONSerialization.data(withJSONObject: stringDict, options: [.prettyPrinted]),
37+
let json = String(data: data, encoding: .utf8) {
38+
print("Request JSON:\n\(json)")
39+
}
40+
} else {
41+
print("Request JSON: null")
42+
}
43+
44+
if let dict = response as? [AnyHashable: Any] {
45+
let stringDict = dict.reduce(into: [String: Any]()) { result, entry in
46+
if let key = entry.key as? String {
47+
result[key] = entry.value
48+
}
49+
}
50+
51+
if let data = try? JSONSerialization.data(withJSONObject: stringDict, options: [.prettyPrinted]),
52+
let json = String(data: data, encoding: .utf8) {
53+
print("Response JSON:\n\(json)")
54+
}
55+
} else {
56+
print("Response JSON: null")
57+
}
58+
print("Error: " + (error.debugDescription));
59+
print("Request Service URL: " + (serviceURL!));
60+
61+
print("Tracing Callback End ********************");
62+
// }
63+
}
64+
65+
2466
}
2567

2668
override class func tearDown() {

0 commit comments

Comments
 (0)