-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
127 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,28 +5,76 @@ | |
// Created by Brandon Sneed on 1/21/21. | ||
// | ||
|
||
#if !os(Linux) | ||
|
||
import XCTest | ||
@testable import Segment | ||
|
||
class HTTPClientTests: XCTestCase { | ||
|
||
override func setUpWithError() throws { | ||
// Put setup code here. This method is called before the invocation of each test method in the class. | ||
RestrictedHTTPSession.reset() | ||
} | ||
|
||
override func tearDownWithError() throws { | ||
// Put teardown code here. This method is called after the invocation of each test method in the class. | ||
} | ||
|
||
/*func testExample() throws { | ||
func testCustomHTTPSessionUpload() throws { | ||
// Use a specific writekey to this test so we do not collide with other cached items. | ||
let analytics = Analytics( | ||
configuration: Configuration(writeKey: "testCustomSesh") | ||
.flushInterval(9999) | ||
.flushAt(9999) | ||
.httpSession(RestrictedHTTPSession()) | ||
) | ||
|
||
waitUntilStarted(analytics: analytics) | ||
|
||
analytics.storage.hardReset(doYouKnowHowToUseThis: true) | ||
|
||
analytics.identify(userId: "brandon", traits: MyTraits(email: "[email protected]")) | ||
|
||
let flushDone = XCTestExpectation(description: "flush done") | ||
analytics.flush { | ||
flushDone.fulfill() | ||
} | ||
|
||
wait(for: [flushDone]) | ||
|
||
XCTAssertEqual(RestrictedHTTPSession.fileUploads, 1) | ||
} | ||
|
||
func testPerformanceExample() throws { | ||
// This is an example of a performance test case. | ||
self.measure { | ||
// Put the code you want to measure the time of here. | ||
|
||
func testDefaultHTTPSessionUpload() throws { | ||
// Use a specific writekey to this test so we do not collide with other cached items. | ||
let analytics = Analytics( | ||
configuration: Configuration(writeKey: "testDefaultSesh") | ||
.flushInterval(9999) | ||
.flushAt(9999) | ||
) | ||
|
||
// reach in and set it, would be the same as the default ultimately | ||
let segment = analytics.find(pluginType: SegmentDestination.self) | ||
XCTAssertTrue(!(segment?.httpClient?.session is RestrictedHTTPSession)) | ||
XCTAssertTrue(segment?.httpClient?.session is URLSession) | ||
segment?.httpClient?.session = RestrictedHTTPSession() | ||
|
||
waitUntilStarted(analytics: analytics) | ||
|
||
analytics.storage.hardReset(doYouKnowHowToUseThis: true) | ||
|
||
analytics.identify(userId: "brandon", traits: MyTraits(email: "[email protected]")) | ||
|
||
let flushDone = XCTestExpectation(description: "flush done") | ||
analytics.flush { | ||
flushDone.fulfill() | ||
} | ||
}*/ | ||
|
||
|
||
wait(for: [flushDone]) | ||
|
||
XCTAssertEqual(RestrictedHTTPSession.fileUploads, 1) | ||
} | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters