Skip to content

Commit 3021fc9

Browse files
test: Delete all folders in http flush tests
Delete all folders after running all http flush tests. Also fix a few minor typos.
1 parent 6b01cf3 commit 3021fc9

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

Tests/SentryTests/Networking/SentryHttpTransportFlushIntegrationTests.swift

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ final class SentryHttpTransportFlushIntegrationTests: XCTestCase {
77
private let flushTimeout: TimeInterval = 5.0
88

99
func testFlush_WhenNoEnvelopes_BlocksAndFinishes() throws {
10-
11-
let (sut, _, _, _) = try getSut()
10+
let (sut, _, fileManager, _) = try getSut()
11+
defer { fileManager.deleteAllFolders() }
1212

1313
var blockingDurationSum: TimeInterval = 0.0
1414
let flushInvocations = 100
@@ -27,13 +27,14 @@ final class SentryHttpTransportFlushIntegrationTests: XCTestCase {
2727

2828
@available(*, deprecated, message: "This is only marked as deprecated because enableAppLaunchProfiling is marked as deprecated. Once that is removed this can be removed.")
2929
func testFlush_WhenNoInternet_BlocksAndFinishes() throws {
30-
let (sut, requestManager, _, dispatchQueueWrapper) = try getSut()
30+
let (sut, requestManager, fileManager, dispatchQueueWrapper) = try getSut()
31+
defer { fileManager.deleteAllFolders() }
3132

3233
requestManager.returnResponse(response: nil)
3334

3435
sut.send(envelope: SentryEnvelope(event: Event()))
3536
sut.send(envelope: SentryEnvelope(event: Event()))
36-
// Wait until the dispath queue drains to confirm the envelope is stored
37+
// Wait until the dispatch queue drains to confirm the envelope is stored
3738
waitForEnvelopeToBeStored(dispatchQueueWrapper)
3839

3940
var blockingDurationSum: TimeInterval = 0.0
@@ -54,12 +55,11 @@ final class SentryHttpTransportFlushIntegrationTests: XCTestCase {
5455
@available(*, deprecated, message: "This is only marked as deprecated because enableAppLaunchProfiling is marked as deprecated. Once that is removed this can be removed.")
5556
func testFlush_CallingFlushDirectlyAfterCapture_Flushes() throws {
5657
let (sut, _, fileManager, dispatchQueueWrapper) = try getSut()
57-
58-
defer { fileManager.deleteAllEnvelopes() }
58+
defer { fileManager.deleteAllFolders() }
5959

6060
for _ in 0..<10 {
6161
sut.send(envelope: SentryEnvelope(event: Event()))
62-
// Wait until the dispath queue drains to confirm the envelope is stored
62+
// Wait until the dispatch queue drains to confirm the envelope is stored
6363
waitForEnvelopeToBeStored(dispatchQueueWrapper)
6464

6565
XCTAssertEqual(sut.flush(self.flushTimeout), .success, "Flush should not time out.")
@@ -70,14 +70,15 @@ final class SentryHttpTransportFlushIntegrationTests: XCTestCase {
7070

7171
@available(*, deprecated, message: "This is only marked as deprecated because enableAppLaunchProfiling is marked as deprecated. Once that is removed this can be removed.")
7272
func testFlushTimesOut_RequestManagerNeverFinishes_FlushingWorksNextTime() throws {
73-
let (sut, requestManager, _, dispatchQueueWrapper) = try getSut()
73+
let (sut, requestManager, fileManager, dispatchQueueWrapper) = try getSut()
74+
defer { fileManager.deleteAllFolders() }
7475

7576
requestManager.waitForResponseDispatchGroup = true
7677
requestManager.responseDispatchGroup.enter()
7778

7879
requestManager.returnResponse(response: nil)
7980
sut.send(envelope: SentryEnvelope(event: Event()))
80-
// Wait until the dispath queue drains to confirm the envelope is stored
81+
// Wait until the dispatch queue drains to confirm the envelope is stored
8182
waitForEnvelopeToBeStored(dispatchQueueWrapper)
8283
requestManager.returnResponse(response: HTTPURLResponse())
8384

@@ -90,7 +91,8 @@ final class SentryHttpTransportFlushIntegrationTests: XCTestCase {
9091

9192
@available(*, deprecated, message: "This is only marked as deprecated because enableAppLaunchProfiling is marked as deprecated. Once that is removed this can be removed.")
9293
func testFlush_CalledMultipleTimes_ImmediatelyReturnsFalse() throws {
93-
let (sut, requestManager, _, dispatchQueueWrapper) = try getSut()
94+
let (sut, requestManager, fileManager, dispatchQueueWrapper) = try getSut()
95+
defer { fileManager.deleteAllFolders() }
9496

9597
// This must be long enough that all the threads we start below get to run
9698
// while the first call to flush is still blocking
@@ -195,7 +197,7 @@ final class SentryHttpTransportFlushIntegrationTests: XCTestCase {
195197
}
196198

197199
private func waitForEnvelopeToBeStored(_ dispatchQueueWrapper: SentryDispatchQueueWrapper) {
198-
// Wait until the dispath queue drains to confirm the envelope is stored
200+
// Wait until the dispatch queue drains to confirm the envelope is stored
199201
let expectation = XCTestExpectation(description: "Envelope sent")
200202
dispatchQueueWrapper.dispatchAsync {
201203
expectation.fulfill()

0 commit comments

Comments
 (0)