Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
brustolin committed Oct 14, 2024
1 parent 35ee4ac commit 734f4f3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ class SentryUIViewControllerPerformanceTrackerTests: XCTestCase {
callbackExpectation.fulfill()
}
let tracer = try XCTUnwrap(transactionSpan as? SentryTracer)
XCTAssertTrue(tracer.shouldIgnore)
XCTAssertEqual(tracer.transactionContext.name, fixture.viewControllerName)
XCTAssertEqual(tracer.transactionContext.nameSource, .component)
XCTAssertEqual(tracer.transactionContext.origin, origin)
Expand Down Expand Up @@ -193,6 +194,7 @@ class SentryUIViewControllerPerformanceTrackerTests: XCTestCase {

lifecycleEndingMethod(sut, viewController, tracker, callbackExpectation, tracer)

XCTAssertFalse(tracer.shouldIgnore)
XCTAssertEqual(Dynamic(transactionSpan).children.asArray!.count, 8)
XCTAssertTrue(tracer.isFinished)
XCTAssertEqual(finishStatus.rawValue, tracer.status.rawValue)
Expand Down
18 changes: 11 additions & 7 deletions Tests/SentryTests/Transaction/SentryTracerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@ class SentryTracerTests: XCTestCase {

let currentDateProvider = TestCurrentDateProvider()
var appStart: Date
var appStartSystemTime: UInt64 {
let res = currentDateProvider.systemTime()
return res
}
lazy var appStartSystemTime = currentDateProvider.systemTime()
var appStartEnd: Date
var appStartDuration = 0.5
let testKey = "extra_key"
Expand Down Expand Up @@ -1219,9 +1216,16 @@ class SentryTracerTests: XCTestCase {
child.shouldIgnore = true

sut.finish()
let transaction = try XCTUnwrap(fixture.hub.capturedTransactionsWithScope.first?.transaction as? Transaction)

XCTAssertEqual(transaction.spans.count, 0)
let transaction = try XCTUnwrap(fixture.hub.capturedTransactionsWithScope.first?.transaction as? [String:Any])
let spans = try XCTUnwrap(transaction["spans"]! as? [[String: Any]])
XCTAssertEqual(spans.count, 0)
}

func testDontCaptureWithShouldIgnoreTrue() throws {
let sut = fixture.getSut()
sut.shouldIgnore = true
sut.finish()
XCTAssertEqual(fixture.hub.capturedTransactionsWithScope.count, 0)
}

#if os(iOS) || os(tvOS) || targetEnvironment(macCatalyst)
Expand Down

0 comments on commit 734f4f3

Please sign in to comment.