From 6129be508e6d2f43ede3ec580e3c3dc77206242e Mon Sep 17 00:00:00 2001 From: Philipp Hofmann Date: Mon, 29 Jan 2024 15:35:34 +0100 Subject: [PATCH] test: Add Scope maxBreadcrumb edge case tests (#3581) Add two test cases for edge cases when adding breadcrumbs. --- Tests/SentryTests/SentryScopeSwiftTests.swift | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Tests/SentryTests/SentryScopeSwiftTests.swift b/Tests/SentryTests/SentryScopeSwiftTests.swift index 2366d5c507b..0f3984560a1 100644 --- a/Tests/SentryTests/SentryScopeSwiftTests.swift +++ b/Tests/SentryTests/SentryScopeSwiftTests.swift @@ -1,3 +1,4 @@ +import Nimble import SentryTestUtils import XCTest @@ -303,6 +304,24 @@ class SentryScopeSwiftTests: XCTestCase { wait(for: [expect], timeout: 0.1) } + func testMaxBreadcrumbs_IsZero() { + let scope = Scope(maxBreadcrumbs: 0) + + scope.addBreadcrumb(fixture.breadcrumb) + + let serialized = scope.serialize() + expect(serialized["breadcrumbs"]) == nil + } + + func testMaxBreadcrumbs_IsNegative() { + let scope = Scope(maxBreadcrumbs: Int.min) + + scope.addBreadcrumb(fixture.breadcrumb) + + let serialized = scope.serialize() + expect(serialized["breadcrumbs"]) == nil + } + func testUseSpanForClear() { fixture.scope.span = fixture.transaction fixture.scope.useSpan { (_) in