Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: read free_memory when the event is captured, not only at SDK startup #1962

Merged
merged 14 commits into from
Jul 18, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 23 additions & 0 deletions Tests/SentryTests/SentryClientTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,29 @@ class SentryClientTest: XCTestCase {
}
}

func testCaptureCrash_FreeMemory() {
var freeMemory = 0
let event = TestData.event
event.threads = nil
event.debugMeta = nil

fixture.getSut().captureCrash(event, with: fixture.scope)

assertLastSentEventWithAttachment { actual in
let eventFreeMemory = actual.context?["device"]?["free_memory"] as? Int
XCTAssertNotNil(eventFreeMemory)
freeMemory = eventFreeMemory ?? 0
}

fixture.getSut().captureCrash(event, with: fixture.scope)

assertLastSentEventWithAttachment { actual in
let eventFreeMemory = actual.context?["device"]?["free_memory"] as? Int
XCTAssertNotNil(eventFreeMemory)
XCTAssertNotEqual(freeMemory, eventFreeMemory)
brustolin marked this conversation as resolved.
Show resolved Hide resolved
}
}

func testCaptureErrorWithUserInfo() {
let expectedValue = "val"
let error = NSError(domain: "domain", code: 0, userInfo: ["key": expectedValue])
Expand Down