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
23 changes: 0 additions & 23 deletions Sentry.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@
62885DA729E946B100554F38 /* TestConncurrentModifications.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62885DA629E946B100554F38 /* TestConncurrentModifications.swift */; };
62950F1029E7FE0100A42624 /* SentryTransactionContextTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62950F0F29E7FE0100A42624 /* SentryTransactionContextTests.swift */; };
629690532AD3E060000185FA /* SentryReachabilitySwiftTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 629690522AD3E060000185FA /* SentryReachabilitySwiftTests.swift */; };
62986F032B03D250008E2D62 /* Nimble in Frameworks */ = {isa = PBXBuildFile; productRef = 62986F022B03D250008E2D62 /* Nimble */; };
62991A8D2BAC1B4A0078A8B8 /* SentryMetricsAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62991A8C2BAC1B4A0078A8B8 /* SentryMetricsAPI.swift */; };
62991A8F2BAC24ED0078A8B8 /* SentryMetricsAPITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62991A8E2BAC24ED0078A8B8 /* SentryMetricsAPITests.swift */; };
62A2F43E2BA9AC10000C9FDD /* DistributionMetric.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62A2F43D2BA9AC10000C9FDD /* DistributionMetric.swift */; };
Expand Down Expand Up @@ -2017,7 +2016,6 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
62986F032B03D250008E2D62 /* Nimble in Frameworks */,
8431F01C29B2854200D8DC56 /* libSentryTestUtils.a in Frameworks */,
D84DAD592B1742C1003CF120 /* SentryTestUtilsDynamic.framework in Frameworks */,
63AA766A1EB8CB2F00D153DE /* Sentry.framework in Frameworks */,
Expand Down Expand Up @@ -4291,7 +4289,6 @@
);
name = SentryTests;
packageProductDependencies = (
62986F022B03D250008E2D62 /* Nimble */,
);
productName = "Tests-iOS";
productReference = 63AA76651EB8CB2F00D153DE /* SentryTests.xctest */;
Expand Down Expand Up @@ -4420,7 +4417,6 @@
);
mainGroup = 6327C5C91EB8A783004E799B;
packageReferences = (
62986F012B03D250008E2D62 /* XCRemoteSwiftPackageReference "Nimble" */,
);
productRefGroup = 6327C5D41EB8A783004E799B /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -7032,25 +7028,6 @@
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */

/* Begin XCRemoteSwiftPackageReference section */
62986F012B03D250008E2D62 /* XCRemoteSwiftPackageReference "Nimble" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/Quick/Nimble";
requirement = {
kind = exactVersion;
version = 10.0.0;
};
};
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
62986F022B03D250008E2D62 /* Nimble */ = {
isa = XCSwiftPackageProductDependency;
package = 62986F012B03D250008E2D62 /* XCRemoteSwiftPackageReference "Nimble" */;
productName = Nimble;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = 6327C5CA1EB8A783004E799B /* Project object */;
}
5 changes: 2 additions & 3 deletions Tests/SentryTests/Categories/SentryNSDataUtilsTests.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import Nimble
import Sentry
import XCTest

Expand All @@ -7,13 +6,13 @@ final class SentryNSDataUtilsTests: XCTestCase {
func testCRC32OfString_SameString_ReturnsSameResult() throws {
let result1 = sentry_crc32ofString("test-string")
let result2 = sentry_crc32ofString("test-string")
expect(result1) == result2
XCTAssertEqual(result1, result2)
}

func testCRC32OfString_DifferentString_ReturnsDifferentResult() throws {
let result1 = sentry_crc32ofString("test-string")
let result2 = sentry_crc32ofString("test-string1")
expect(result1) != result2
XCTAssertNotEqual(result1, result2)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class SentryAppStateManagerTests: XCTestCase {
func testUpdateAppState() {
sut.storeCurrentAppState()

XCTAssertEqual(fixture.fileManager.readAppState()!.wasTerminated, false)
XCTAssertFalse(fixture.fileManager.readAppState()!.wasTerminated)

sut.updateAppState { state in
state.wasTerminated = true
Expand Down
5 changes: 2 additions & 3 deletions Tests/SentryTests/Helper/SentryAppStateTests.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import Nimble
import XCTest

class SentryAppStateTests: XCTestCase {
Expand All @@ -23,15 +22,15 @@ class SentryAppStateTests: XCTestCase {

let actual = appState.serialize()

expect(actual["release_name"]) == nil
XCTAssertNil(actual["release_name"])
}

func testInitWithJSON_ReleaseNameIsNil_DoesNotAddReleaseName() {
let appState = SentryAppState(releaseName: nil, osVersion: "14.4.1", vendorId: TestData.someUUID, isDebugging: false, systemBootTimestamp: TestData.timestamp)

let actual = SentryAppState(jsonObject: appState.serialize())

expect(actual?.releaseName) == nil
XCTAssertNil(actual?.releaseName)
}

func testInitWithJSON_AllFields() throws {
Expand Down
3 changes: 1 addition & 2 deletions Tests/SentryTests/Helper/SentryDateUtilTests.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import Nimble
import SentryTestUtils
import XCTest

Expand Down Expand Up @@ -60,7 +59,7 @@ class SentryDateUtilTests: XCTestCase {
let testDate = Date(timeIntervalSince1970: 60)
let timestamp = SentryDateUtil.millisecondsSince1970(testDate)

expect(timestamp) == 60_000
XCTAssertEqual(timestamp, 60_000)
}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import Nimble
import XCTest

#if os(iOS) || os(tvOS) || targetEnvironment(macCatalyst)
Expand All @@ -9,7 +8,7 @@ final class SentryDependencyContainerTests: XCTestCase {
framesTracker.start()
SentryDependencyContainer.reset()

expect(framesTracker.isRunning) == false
XCTAssertFalse(framesTracker.isRunning)
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import Nimble
@testable import Sentry
import XCTest

Expand All @@ -7,7 +6,7 @@ final class SentryEnabledFeaturesBuilderTests: XCTestCase {
func testDefaultFeatures() throws {
let features = SentryEnabledFeaturesBuilder.getEnabledFeatures(options: Options())

expect(features) == ["captureFailedRequests"]
XCTAssertEqual(features, ["captureFailedRequests"])
}

func testEnableAllFeatures() throws {
Expand All @@ -30,23 +29,19 @@ final class SentryEnabledFeaturesBuilderTests: XCTestCase {

let features = SentryEnabledFeaturesBuilder.getEnabledFeatures(options: options)

expect(features).to(contain([
"captureFailedRequests",
"performanceV2",
"timeToFullDisplayTracing",
"swiftAsyncStacktraces",
"metrics"
]))
XCTAssert(features.contains("captureFailedRequests"))
XCTAssert(features.contains("performanceV2"))
XCTAssert(features.contains("timeToFullDisplayTracing"))
XCTAssert(features.contains("swiftAsyncStacktraces"))
XCTAssert(features.contains("metrics"))

#if os(iOS) || os(macOS) || targetEnvironment(macCatalyst)
expect(features).to(contain(["appLaunchProfiling"]))
XCTAssert(features.contains("appLaunchProfiling"))
#endif // os(iOS) || os(macOS) || targetEnvironment(macCatalyst)

#if os(iOS) || os(tvOS)
#if canImport(UIKit) && !SENTRY_NO_UIKIT
expect(features).to(contain([
"preWarmedAppStartTracing"
]))
XCTAssert(features.contains("preWarmedAppStartTracing"))
#endif // canImport(UIKit)
#endif // os(iOS) || os(tvOS)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ final class SentryExtraContextProviderTests: XCTestCase {
XCTAssertEqual(app?["app_memory"] as? UInt64, fixture.crashWrapper.internalAppMemorySize)
}

func testExtraDeviceInfo() {
func testExtraDeviceInfo() throws {
#if os(iOS) || targetEnvironment(macCatalyst)
let sut = fixture.getSut()
fixture.deviceWrapper.internalOrientation = .landscapeLeft
Expand All @@ -56,7 +56,7 @@ final class SentryExtraContextProviderTests: XCTestCase {
let device = actualContext["device"] as? [String: Any]

XCTAssertEqual(device?["orientation"] as? String, "landscape")
XCTAssertEqual(device?["charging"] as? Bool, false)
XCTAssertFalse(try XCTUnwrap(device?["charging"] as? Bool))
XCTAssertEqual(device?["battery_level"] as? UInt, 44)
#endif // os(iOS) || targetEnvironment(macCatalyst)
}
Expand Down
45 changes: 22 additions & 23 deletions Tests/SentryTests/Helper/SentryFileManagerTests.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import Nimble
import Sentry
import SentryTestUtils
import XCTest
Expand Down Expand Up @@ -153,15 +152,15 @@ class SentryFileManagerTests: XCTestCase {
let dsStoreFile = "\(sut.basePath)/.DS_Store"

let result = FileManager.default.createFile(atPath: dsStoreFile, contents: "some data".data(using: .utf8))
expect(result) == true
XCTAssertEqual(result, true)

sut.deleteOldEnvelopeItems()

let logMessages = logOutput.loggedMessages.filter {
$0.contains("[Sentry] [debug]") &&
$0.contains("Ignoring .DS_Store file when building envelopes path at path: \(dsStoreFile)")
}
expect(logMessages.count) == 1
XCTAssertEqual(logMessages.count, 1)

try FileManager.default.removeItem(atPath: dsStoreFile)
}
Expand All @@ -176,15 +175,15 @@ class SentryFileManagerTests: XCTestCase {
let textFilePath = "\(sut.basePath)/something.txt"

let result = FileManager.default.createFile(atPath: textFilePath, contents: "some data".data(using: .utf8))
expect(result) == true
XCTAssertEqual(result, true)

sut.deleteOldEnvelopeItems()

let logMessages = logOutput.loggedMessages.filter {
$0.contains("[Sentry] [debug]") &&
$0.contains("Ignoring non directory when deleting old envelopes at path: \(textFilePath)")
}
expect(logMessages.count) == 1
XCTAssertEqual(logMessages.count, 1)

try FileManager.default.removeItem(atPath: textFilePath)
}
Expand All @@ -199,13 +198,13 @@ class SentryFileManagerTests: XCTestCase {
let nonExistentFile = "nonExistentFile.txt"
let nonExistentFileFullPath = "\(sut.basePath)/\(nonExistentFile)"

expect(sut.getEnvelopesPath(nonExistentFile)) == nil
XCTAssertNil(sut.getEnvelopesPath(nonExistentFile))

let logMessages = logOutput.loggedMessages.filter {
$0.contains("[Sentry] [warning]") &&
$0.contains("Could not get attributes of item at path: \(nonExistentFileFullPath)")
}
expect(logMessages.count) == 1
XCTAssertEqual(logMessages.count, 1)
}

func testDeleteOldEnvelopes_WithEmptyDSN() throws {
Expand Down Expand Up @@ -546,11 +545,11 @@ class SentryFileManagerTests: XCTestCase {
sut.getAllEnvelopes()

let debugLogMessages = logOutput.loggedMessages.filter { $0.contains("[Sentry] [info]") && $0.contains("Returning empty files list, as folder doesn't exist at path:") }
expect(debugLogMessages.count) == 1
XCTAssertEqual(debugLogMessages.count, 1)

let errorMessages = logOutput.loggedMessages.filter { $0.contains("[Sentry] [error]") }

expect(errorMessages.count) == 0
XCTAssertEqual(errorMessages.count, 0)
}

func testReadStoreDeleteAppState() {
Expand Down Expand Up @@ -718,13 +717,13 @@ extension SentryFileManagerTests {
// if app launch profiling was configured to take place
func testAppLaunchProfileConfigFileExists_fileExists() throws {
try ensureAppLaunchProfileConfig()
expect(appLaunchProfileConfigFileExists()) == true
XCTAssertEqual(appLaunchProfileConfigFileExists(), true)
}

// if app launch profiling was not configured to take place
func testAppLaunchProfileConfigFileExists_fileDoesNotExist() throws {
try ensureAppLaunchProfileConfig(exists: false)
expect(appLaunchProfileConfigFileExists()) == false
XCTAssertFalse(appLaunchProfileConfigFileExists())
}

func testAppLaunchProfileConfiguration() throws {
Expand All @@ -734,14 +733,14 @@ extension SentryFileManagerTests {
let config = appLaunchProfileConfiguration()
let actualTracesSampleRate = try XCTUnwrap(config?[kSentryLaunchProfileConfigKeyTracesSampleRate]).doubleValue
let actualProfilesSampleRate = try XCTUnwrap(config?[kSentryLaunchProfileConfigKeyProfilesSampleRate]).doubleValue
expect(actualTracesSampleRate) == expectedTracesSampleRate
expect(actualProfilesSampleRate) == expectedProfilesSampleRate
XCTAssertEqual(actualTracesSampleRate, expectedTracesSampleRate)
XCTAssertEqual(actualProfilesSampleRate, expectedProfilesSampleRate)
}

// if a file isn't present when we expect it to be, like if there was an issue when we went to write it to disk
func testAppLaunchProfileConfiguration_noConfigurationExists() throws {
try ensureAppLaunchProfileConfig(exists: false)
expect(appLaunchProfileConfiguration()) == nil
XCTAssertNil(appLaunchProfileConfiguration())
}

func testWriteAppLaunchProfilingConfigFile_noCurrentFileExists() throws {
Expand All @@ -758,8 +757,8 @@ extension SentryFileManagerTests {

let actualTracesSampleRate = try XCTUnwrap(config?[kSentryLaunchProfileConfigKeyTracesSampleRate] as? NSNumber).doubleValue
let actualProfilesSampleRate = try XCTUnwrap(config?[kSentryLaunchProfileConfigKeyProfilesSampleRate] as? NSNumber).doubleValue
expect(actualTracesSampleRate) == expectedTracesSampleRate
expect(actualProfilesSampleRate) == expectedProfilesSampleRate
XCTAssertEqual(actualTracesSampleRate, expectedTracesSampleRate)
XCTAssertEqual(actualProfilesSampleRate, expectedProfilesSampleRate)
}

// if a file is still present in the primary location, like if a crash occurred before it could be removed, or an error occurred when trying to remove it or move it to the backup location, make sure we overwrite it
Expand All @@ -777,23 +776,23 @@ extension SentryFileManagerTests {

let actualTracesSampleRate = try XCTUnwrap(config?[kSentryLaunchProfileConfigKeyTracesSampleRate] as? NSNumber).doubleValue
let actualProfilesSampleRate = try XCTUnwrap(config?[kSentryLaunchProfileConfigKeyProfilesSampleRate] as? NSNumber).doubleValue
expect(actualTracesSampleRate) == expectedTracesSampleRate
expect(actualProfilesSampleRate) == expectedProfilesSampleRate
XCTAssertEqual(actualTracesSampleRate, expectedTracesSampleRate)
XCTAssertEqual(actualProfilesSampleRate, expectedProfilesSampleRate)
}

func testRemoveAppLaunchProfilingConfigFile() throws {
try ensureAppLaunchProfileConfig(exists: true)
expect(NSDictionary(contentsOf: launchProfileConfigFileURL())) != nil
XCTAssertNotNil(NSDictionary(contentsOf: launchProfileConfigFileURL()))
removeAppLaunchProfilingConfigFile()
expect(NSDictionary(contentsOf: launchProfileConfigFileURL())) == nil
XCTAssertNil(NSDictionary(contentsOf: launchProfileConfigFileURL()))
}

// if there's not a file when we expect one, just make sure we don't crash
func testRemoveAppLaunchProfilingConfigFile_noFileExists() throws {
try ensureAppLaunchProfileConfig(exists: false)
expect(NSDictionary(contentsOf: launchProfileConfigFileURL())) == nil
XCTAssertNil(NSDictionary(contentsOf: launchProfileConfigFileURL()))
removeAppLaunchProfilingConfigFile()
expect(NSDictionary(contentsOf: launchProfileConfigFileURL())) == nil
XCTAssertNil(NSDictionary(contentsOf: launchProfileConfigFileURL()))
}

func testCheckForLaunchProfilingConfigFile_URLDoesNotExist() {
Expand All @@ -804,7 +803,7 @@ extension SentryFileManagerTests {
sentryLaunchConfigFileURL = nil

// make sure we return a default-off value and also don't crash the call to access()
expect(appLaunchProfileConfigFileExists()) == false
XCTAssertFalse(appLaunchProfileConfigFileExists())

// set the original value back so other tests don't crash
sentryLaunchConfigFileURL = (originalURL as NSURL)
Expand Down
3 changes: 1 addition & 2 deletions Tests/SentryTests/Helper/SentrySerializationTests.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import Nimble
@testable import Sentry
import XCTest

Expand Down Expand Up @@ -245,7 +244,7 @@ class SentrySerializationTests: XCTestCase {

let serialized = String(data: data, encoding: .utf8)

expect(serialized) == "{\"segment_id\":5}\n[{\"KEY\":\"VALUE\"}]"
XCTAssertEqual(serialized, "{\"segment_id\":5}\n[{\"KEY\":\"VALUE\"}]")
}

func testLevelFromEventData() {
Expand Down
Loading