Skip to content

Commit 813085b

Browse files
committed
More test updates
1 parent b84020e commit 813085b

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

Sources/Segment/Utilities/UserAgent.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ internal struct UserAgent {
8484
#endif
8585

8686
#else
87+
// tvos has no user agent.
8788
return "unknown"
8889
#endif
8990
}

Tests/Segment-Tests/StressTests.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// Created by Brandon Sneed on 11/4/21.
66
//
77

8-
#if !os(Linux) && !os(tvOS) && !os(watchOS) && !os(Windows)
8+
#if !os(Linux) && !os(tvOS) && !os(watchOS) && !os(visionOS) && !os(Windows)
99

1010
import XCTest
1111
@testable import Segment
@@ -38,6 +38,10 @@ class StressTests: XCTestCase {
3838

3939
DirectoryStore.fileValidator = { url in
4040
do {
41+
if FileManager.default.fileExists(atPath: url.path) == false {
42+
XCTFail("File doesn't exist when it should! \(url)")
43+
return
44+
}
4145
let eventBundle = try JSONSerialization.jsonObject(with: Data(contentsOf: url))
4246
XCTAssertNotNil(eventBundle, "The event bundle parsed out to null. \(url)")
4347
} catch {
@@ -117,6 +121,10 @@ class StressTests: XCTestCase {
117121

118122
DirectoryStore.fileValidator = { url in
119123
do {
124+
if FileManager.default.fileExists(atPath: url.path) == false {
125+
XCTFail("File doesn't exist when it should! \(url)")
126+
return
127+
}
120128
let eventBundle = try JSONSerialization.jsonObject(with: Data(contentsOf: url))
121129
XCTAssertNotNil(eventBundle, "The event bundle parsed out to null. \(url)")
122130
} catch {

Tests/Segment-Tests/UserAgentTests.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,19 @@ final class UserAgentTests: XCTestCase {
5555
print("Generated UserAgent: \(userAgent)")
5656
}
5757

58+
#if !os(tvOS) && !os(watchOS)
5859
func testUserAgentWithCustomAppName() throws {
60+
/*#if canImport(WebKit)
61+
let wkUserAgent = WKWebView().value(forKey: "userAgent") as! String
62+
#else
63+
let wkUserAgent = "unknown"
64+
#endif
65+
print(wkUserAgent)*/
66+
5967
let customUA = UserAgent.value(applicationName: "MyApp/1.0")
6068
XCTAssertTrue(customUA.contains("MyApp/1.0"), "Should contain custom app name")
6169
}
70+
#endif
6271

6372
func testUserAgentCaching() throws {
6473
let ua1 = UserAgent.value

0 commit comments

Comments
 (0)