Skip to content

Commit

Permalink
Cleanup pre-code-review
Browse files Browse the repository at this point in the history
  • Loading branch information
jdjackson committed Dec 5, 2024
1 parent 8440d72 commit 4dbf3f0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 14 deletions.
3 changes: 2 additions & 1 deletion Sources/Crashes/CrashCollection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,11 @@ public final class CrashCollection {
Logger.general.debug("Received matching value for CRCID: \(receivedCRCID), no update necessary")
}
} else {
Logger.general.debug("No value for CRCID header: \(Const.crcidKey), clearing local crcid value")
Logger.general.debug("No value for CRCID header: \(Const.crcidKey), clearing local crcid value if present")
self.crashCollectionStorage.removeObject(forKey: Const.crcidKey)
}
case .failure(let failure):
// TODO: Is it worth sending a pixel for this case, so that we can monitor for missing crash reports?

Check failure on line 108 in Sources/Crashes/CrashCollection.swift

View workflow job for this annotation

GitHub Actions / Run SwiftLint

TODOs should be resolved (Is it worth sending a pixel fo...) (todo)
Logger.general.debug("Crash Collection - Sending Crash Report: failed (\(failure))")
}
}
Expand Down
6 changes: 1 addition & 5 deletions Sources/Crashes/CrashReportSender.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,8 @@ enum CrashReportSenderError: Error {
// By conforming to a protocol, we can sub in mocks more easily
public final class CrashReportSender: CrashReportSending {

#if DEBUG
// TODO: Why is a breakpoint here hit twice?
static let reportServiceUrl = URL(string: "https://9e3c-20-75-144-152.ngrok-free.app/crash.js")!
#else
static let reportServiceUrl = URL(string: "https://duckduckgo.com/crash.js")!
#endif

static let httpHeaderCRCID = "crcid"

Check failure on line 38 in Sources/Crashes/CrashReportSender.swift

View workflow job for this annotation

GitHub Actions / Run SwiftLint

Lines should not have trailing whitespace (trailing_whitespace)
public let platform: CrashCollectionPlatform
Expand Down
10 changes: 2 additions & 8 deletions Tests/CrashesTests/CrashCollectionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ class CrashCollectionTests: XCTestCase {
XCTAssertFalse(crashCollection.isFirstCrash)
}

func testCRCIDIsUpdatedWhenNoLocalValueIsPresent()
{
func testCRCIDIsStoredWhenReceived() {
let responseCRCIDValue = "CRCID Value"

let store = MockKeyValueStore()
Expand Down Expand Up @@ -121,13 +120,8 @@ class CrashCollectionTests: XCTestCase {

XCTAssertNil(store.object(forKey: CrashCollection.Const.crcidKey), "CRCID should not be present in the store after receiving a successful response")
}

// TODO: Too redundant with the above to be worthwhile?
// func testCRCIDIsOverwrittenWhenServerProvidesNewValue() {
// // TODO: Implement
// }

func testCRCIDIsRetainedWhenErrorIsReceived() {
func testCRCIDIsRetainedWhenServerErrorIsReceived() {
let store = MockKeyValueStore()
let crashReportSender = MockCrashReportSender(platform: .iOS)
let crashCollection = CrashCollection(crashReportSender: crashReportSender , crashCollectionStorage: store)
Expand Down

0 comments on commit 4dbf3f0

Please sign in to comment.