Skip to content

Commit

Permalink
chore: clean up tests (#2484)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinrenskers authored Dec 5, 2022
1 parent c6fb5a9 commit 57e140e
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 12 deletions.
3 changes: 3 additions & 0 deletions Sentry.xcodeproj/xcshareddata/xcschemes/Sentry.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@
<Test
Identifier = "SentryOutOfMemoryIntegrationTests/testANRDetected_UpdatesAppStateToTrue_disabled()">
</Test>
<Test
Identifier = "SentryProfilerSwiftTests/testProfileTimeoutTimer_disabled()">
</Test>
<Test
Identifier = "SentrySDKIntegrationTestsBase">
</Test>
Expand Down
1 change: 0 additions & 1 deletion Sources/Sentry/SentryFileManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ - (nullable instancetype)initWithOptions:(SentryOptions *)options
self.currentFileCounter = 0;
self.maxEnvelopes = options.maxCacheItems;

SENTRY_LOG_DEBUG(@"Dispatching deletion of old envelopes from %@", self);
[dispatchQueueWrapper
dispatchAfter:10
block:^{
Expand Down
7 changes: 5 additions & 2 deletions Tests/SentryTests/Helper/SentryFileManagerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ class SentryFileManagerTests: XCTestCase {
init() {
currentDateProvider = TestCurrentDateProvider()
dispatchQueueWrapper = TestSentryDispatchQueueWrapper()
dispatchQueueWrapper.dispatchAfterExecutesBlock = true


eventIds = (0...(maxCacheItems + 10)).map { _ in SentryId() }

options = Options()
Expand Down Expand Up @@ -135,6 +134,8 @@ class SentryFileManagerTests: XCTestCase {
}

func testDeleteOldEnvelopes() throws {
fixture.dispatchQueueWrapper.dispatchAfterExecutesBlock = true

let envelope = TestConstants.envelope
let path = sut.store(envelope)

Expand All @@ -147,6 +148,8 @@ class SentryFileManagerTests: XCTestCase {
sut = fixture.getSut()

XCTAssertEqual(sut.getAllEnvelopes().count, 0)

fixture.dispatchQueueWrapper.dispatchAfterExecutesBlock = false
}

func testDontDeleteYoungEnvelopes() throws {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ class TestSentryDispatchQueueWrapper: SentryDispatchQueueWrapper {
/// - SeeAlso: `delayDispatches`, which controls whether the block should execute immediately or with the requested delay.
var dispatchAfterExecutesBlock = false

/// If `true`, delay dispatched block execution by the specified duration. Be sure to set expectations in test code that relies on delayed dispatches.
var delayDispatches = false

override func dispatchAsync(_ block: @escaping () -> Void) {
dispatchAsyncCalled += 1
block()
Expand Down Expand Up @@ -39,11 +36,7 @@ class TestSentryDispatchQueueWrapper: SentryDispatchQueueWrapper {
dispatchAfterInvocations.record((interval, block))
if blockBeforeMainBlock() {
if dispatchAfterExecutesBlock {
if delayDispatches {
DispatchQueue.main.asyncAfter(deadline: .now() + interval, execute: .init(block: block))
} else {
block()
}
block()
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/SentryTests/Profiling/SentryProfilerSwiftTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class SentryProfilerSwiftTests: XCTestCase {
}
}

func testProfileTimeoutTimer() {
func testProfileTimeoutTimer_disabled() {
fixture.options.profilesSampleRate = 1.0
fixture.options.tracesSampleRate = 1.0
performTest(shouldTimeOut: true)
Expand Down

0 comments on commit 57e140e

Please sign in to comment.