Skip to content

Commit

Permalink
Remove debug command enum, protocol, and usage
Browse files Browse the repository at this point in the history
  • Loading branch information
aataraxiaa committed May 9, 2024
1 parent 44a4b7b commit eb505a0
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 77 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ enum DataBrokerProtectionQueueMode {
}
}

protocol DataBrokerProtectionQueueManager: DataBrokerDebugCommandExecutor {
protocol DataBrokerProtectionQueueManager {

init(operationQueue: DataBrokerProtectionOperationQueue,
operationsCreator: DataBrokerOperationsCreator,
Expand Down Expand Up @@ -113,19 +113,6 @@ final class DefaultDataBrokerProtectionQueueManager: DataBrokerProtectionQueueMa
}
}

extension DefaultDataBrokerProtectionQueueManager {
func execute(_ command: DataBrokerDebugCommand) {
guard case .startOptOutOperations(let showWebView,
let operationDependencies,
let completion) = command else { return }

addOperations(withType: .optOut,
showWebView: showWebView,
operationDependencies: operationDependencies,
completion: completion)
}
}

private extension DefaultDataBrokerProtectionQueueManager {

func startOperationsIfPermitted(forNewMode newMode: DataBrokerProtectionQueueMode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,20 +335,25 @@ public final class DefaultDataBrokerProtectionScheduler: DataBrokerProtectionSch

os_log("Opting out all brokers...", log: .dataBrokerProtection)
self.currentOperation = .optOutAll
queueManager.execute(.startOptOutOperations(showWebView: showWebView, operationDependencies: operationDependencies) { [weak self] errors in
if let errors = errors {
if let oneTimeError = errors.oneTimeError {
os_log("Error during DefaultDataBrokerProtectionScheduler.optOutAllBrokers in dataBrokerProcessor.runAllOptOutOperations(), error: %{public}@", log: .dataBrokerProtection, oneTimeError.localizedDescription)
self?.pixelHandler.fire(.generalError(error: oneTimeError, functionOccurredIn: "DefaultDataBrokerProtectionScheduler.optOutAllBrokers"))
}
if let operationErrors = errors.operationErrors,
operationErrors.count != 0 {
os_log("Operation error(s) during DefaultDataBrokerProtectionScheduler.optOutAllBrokers in dataBrokerProcessor.runAllOptOutOperations(), count: %{public}d", log: .dataBrokerProtection, operationErrors.count)
}
}
self?.currentOperation = .idle
completion?(errors)
})
// TODO: Re-implement based on WIP debug command protocol

Check failure on line 338 in LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Scheduler/DataBrokerProtectionScheduler.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

TODOs should be resolved (Re-implement based on WIP debu...) (todo)
/*
This was based on my implementation of `debugCommands`. However, based on Elle's work and the outcomes, my approach is not feasible.
we will need to implement the debug protocol including as part of Elle's work
*/
// queueManager.execute(.startOptOutOperations(showWebView: showWebView, operationDependencies: operationDependencies) { [weak self] errors in
// if let errors = errors {
// if let oneTimeError = errors.oneTimeError {
// os_log("Error during DefaultDataBrokerProtectionScheduler.optOutAllBrokers in dataBrokerProcessor.runAllOptOutOperations(), error: %{public}@", log: .dataBrokerProtection, oneTimeError.localizedDescription)
// self?.pixelHandler.fire(.generalError(error: oneTimeError, functionOccurredIn: "DefaultDataBrokerProtectionScheduler.optOutAllBrokers"))
// }
// if let operationErrors = errors.operationErrors,
// operationErrors.count != 0 {
// os_log("Operation error(s) during DefaultDataBrokerProtectionScheduler.optOutAllBrokers in dataBrokerProcessor.runAllOptOutOperations(), count: %{public}d", log: .dataBrokerProtection, operationErrors.count)
// }
// }
// self?.currentOperation = .idle
// completion?(errors)
// })
}

public func getDebugMetadata(completion: (DBPBackgroundAgentMetadata?) -> Void) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,24 +222,4 @@ final class DataBrokerProtectionQueueManagerTests: XCTestCase {
await fulfillment(of: [expectation], timeout: 3)
XCTAssert(errorCollection.operationErrors?.count == 5)
}

// Test execute debug
func testWhenCallDebugOptOutCommand_thenOptOutOperationsAreCreated() throws {
// Given
sut = DefaultDataBrokerProtectionQueueManager(operationQueue: mockQueue,
operationsCreator: mockOperationsCreator,
mismatchCalculator: mockMismatchCalculator,
brokerUpdater: mockUpdater)
let expectedConcurrentOperations = DataBrokerProtectionProcessorConfiguration().concurrentOperationsFor(.optOut)
XCTAssert(mockOperationsCreator.createdType == .scan)

// When
sut.execute(.startOptOutOperations(showWebView: false,
operationDependencies: mockDependencies,
completion: nil))

// Then
XCTAssert(mockOperationsCreator.createdType == .optOut)
XCTAssertEqual(mockQueue.maxConcurrentOperationCount, expectedConcurrentOperations)
}
}

0 comments on commit eb505a0

Please sign in to comment.