Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Tests/SentryTests/Helper/SentryFileManagerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1082,13 +1082,19 @@ class SentryFileManagerTests: XCTestCase {

let path = fixture.getTooLongPath()
var error: NSError?

// -- Act --
let result = createDirectoryIfNotExists(path, &error)

// -- Assert -
XCTAssertFalse(result)
XCTAssertEqual(error?.domain, SentryErrorDomain)
XCTAssertEqual(error?.code, 108)
XCTAssertEqual(logOutput.loggedMessages.count, 1)

let expectedLogMessage = "Failed to create directory, path is too long: \(path)"
let logMessagesContainsExpected = logOutput.loggedMessages.contains { $0.contains("[Sentry] [fatal]") && $0.contains(expectedLogMessage) }

XCTAssertTrue(logMessagesContainsExpected, "Expected fatal log with message: \(expectedLogMessage)")
}

func testCreateDirectoryIfNotExists_otherError_shouldNotLogError() throws {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ class SentryWatchdogTerminationTrackerTests: NotificationCenterTestCase {
let appState = SentryAppState(releaseName: fixture.options.releaseName ?? "", osVersion: UIDevice.current.systemVersion, vendorId: TestData.someUUID, isDebugging: false, systemBootTimestamp: fixture.sysctl.systemBootTimestamp)

XCTAssertEqual(appState, actual)
XCTAssertEqual(1, fixture.dispatchQueue.dispatchAsyncCalled)

XCTAssertGreaterThanOrEqual(fixture.dispatchQueue.dispatchAsyncCalled, 1, "Expected at least 1 dispatchAsync call for start to ensure we don't run reading the app state on the calling thread.")
}

func testGoToForeground_SetsIsActive() throws {
Expand All @@ -126,7 +127,7 @@ class SentryWatchdogTerminationTrackerTests: NotificationCenterTestCase {
let appState2 = try XCTUnwrap(fixture.fileManager.readAppState())
XCTAssertFalse(appState2.isActive, "Expected appSate to be inactive after going to background.")

XCTAssertGreaterThanOrEqual(fixture.dispatchQueue.dispatchAsyncCalled, 3, "Expected at least 3 dispatchAsync calls (start, foreground, background) to ensure we don't run reading the app state on the calling thread. ")
XCTAssertGreaterThanOrEqual(fixture.dispatchQueue.dispatchAsyncCalled, 3, "Expected at least 3 dispatchAsync calls (start, foreground, background) to ensure we don't run reading the app state on the calling thread.")
}

func testGoToForeground_WhenAppStateNil_NothingIsStored() {
Expand Down
Loading