Skip to content

Commit

Permalink
Update impacted tests & mocks
Browse files Browse the repository at this point in the history
  • Loading branch information
aataraxiaa committed Sep 3, 2024
1 parent 64f71b5 commit a6c9d8d
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 98 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ final class DataBrokerProtectionAgentManagerTests: XCTestCase {
private var mockDependencies: DefaultDataBrokerOperationDependencies!
private var mockProfile: DataBrokerProtectionProfile!
private var mockAgentStopper: MockAgentStopper!
private var mockFreemiumPIRUserState: MockFreemiumPIRUserState!
private var mockFreemiumPIRUserStateManager: MockFreemiumPIRUserStateManager!

override func setUpWithError() throws {

Expand Down Expand Up @@ -68,7 +68,7 @@ final class DataBrokerProtectionAgentManagerTests: XCTestCase {
phones: [],
birthYear: 1992)

mockFreemiumPIRUserState = MockFreemiumPIRUserState()
mockFreemiumPIRUserStateManager = MockFreemiumPIRUserStateManager()
}

func testWhenAgentStart_andProfileExists_andUserIsNotFreemium_thenActivityIsScheduled_andScheduledAllOperationsRun() async throws {
Expand All @@ -82,10 +82,10 @@ final class DataBrokerProtectionAgentManagerTests: XCTestCase {
operationDependencies: mockDependencies,
pixelHandler: mockPixelHandler,
agentStopper: mockAgentStopper,
freemiumPIRUserStateManager: mockFreemiumPIRUserState)
freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager)

mockDataManager.profileToReturn = mockProfile
mockFreemiumPIRUserState.isActiveUser = false
mockFreemiumPIRUserStateManager.isActiveUser = false

let schedulerStartedExpectation = XCTestExpectation(description: "Scheduler started")
var schedulerStarted = false
Expand Down Expand Up @@ -121,10 +121,10 @@ final class DataBrokerProtectionAgentManagerTests: XCTestCase {
operationDependencies: mockDependencies,
pixelHandler: mockPixelHandler,
agentStopper: mockAgentStopper,
freemiumPIRUserStateManager: mockFreemiumPIRUserState)
freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager)

mockDataManager.profileToReturn = mockProfile
mockFreemiumPIRUserState.isActiveUser = true
mockFreemiumPIRUserStateManager.isActiveUser = true

let schedulerStartedExpectation = XCTestExpectation(description: "Scheduler started")
var schedulerStarted = false
Expand Down Expand Up @@ -156,7 +156,7 @@ final class DataBrokerProtectionAgentManagerTests: XCTestCase {
entitlementMonitor: DataBrokerProtectionEntitlementMonitor(),
authenticationManager: MockAuthenticationManager(),
pixelHandler: mockPixelHandler,
stopAction: mockStopAction, freemiumPIRUserStateManager: MockFreemiumPIRUserState())
stopAction: mockStopAction, freemiumPIRUserStateManager: MockFreemiumPIRUserStateManager())
sut = DataBrokerProtectionAgentManager(
userNotificationService: mockNotificationService,
activityScheduler: mockActivityScheduler,
Expand All @@ -166,10 +166,10 @@ final class DataBrokerProtectionAgentManagerTests: XCTestCase {
operationDependencies: mockDependencies,
pixelHandler: mockPixelHandler,
agentStopper: agentStopper,
freemiumPIRUserStateManager: mockFreemiumPIRUserState)
freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager)

mockDataManager.profileToReturn = nil
mockFreemiumPIRUserState.isActiveUser = true
mockFreemiumPIRUserStateManager.isActiveUser = true

let stopAgentExpectation = XCTestExpectation(description: "Stop agent expectation")

Expand Down Expand Up @@ -200,7 +200,7 @@ final class DataBrokerProtectionAgentManagerTests: XCTestCase {
operationDependencies: mockDependencies,
pixelHandler: mockPixelHandler,
agentStopper: mockAgentStopper,
freemiumPIRUserStateManager: mockFreemiumPIRUserState)
freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager)

mockDataManager.profileToReturn = nil

Expand Down Expand Up @@ -238,10 +238,10 @@ final class DataBrokerProtectionAgentManagerTests: XCTestCase {
operationDependencies: mockDependencies,
pixelHandler: mockPixelHandler,
agentStopper: mockAgentStopper,
freemiumPIRUserStateManager: mockFreemiumPIRUserState)
freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager)

mockDataManager.profileToReturn = mockProfile
mockFreemiumPIRUserState.isActiveUser = false
mockFreemiumPIRUserStateManager.isActiveUser = false

var startScheduledScansCalled = false
mockQueueManager.startScheduledAllOperationsIfPermittedCalledCompletion = { _ in
Expand All @@ -266,10 +266,10 @@ final class DataBrokerProtectionAgentManagerTests: XCTestCase {
operationDependencies: mockDependencies,
pixelHandler: mockPixelHandler,
agentStopper: mockAgentStopper,
freemiumPIRUserStateManager: mockFreemiumPIRUserState)
freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager)

mockDataManager.profileToReturn = mockProfile
mockFreemiumPIRUserState.isActiveUser = true
mockFreemiumPIRUserStateManager.isActiveUser = true

var startScheduledScansCalled = false
mockQueueManager.startScheduledScanOperationsIfPermittedCalledCompletion = { _ in
Expand All @@ -294,10 +294,10 @@ final class DataBrokerProtectionAgentManagerTests: XCTestCase {
operationDependencies: mockDependencies,
pixelHandler: mockPixelHandler,
agentStopper: mockAgentStopper,
freemiumPIRUserStateManager: mockFreemiumPIRUserState)
freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager)

mockDataManager.profileToReturn = mockProfile
mockFreemiumPIRUserState.isActiveUser = false
mockFreemiumPIRUserStateManager.isActiveUser = false

var startImmediateScansCalled = false
mockQueueManager.startImmediateScanOperationsIfPermittedCalledCompletion = { _ in
Expand All @@ -322,10 +322,10 @@ final class DataBrokerProtectionAgentManagerTests: XCTestCase {
operationDependencies: mockDependencies,
pixelHandler: mockPixelHandler,
agentStopper: mockAgentStopper,
freemiumPIRUserStateManager: mockFreemiumPIRUserState)
freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager)

mockDataManager.profileToReturn = mockProfile
mockFreemiumPIRUserState.isActiveUser = true
mockFreemiumPIRUserStateManager.isActiveUser = true

var startImmediateScansCalled = false
mockQueueManager.startImmediateScanOperationsIfPermittedCalledCompletion = { _ in
Expand All @@ -350,7 +350,7 @@ final class DataBrokerProtectionAgentManagerTests: XCTestCase {
operationDependencies: mockDependencies,
pixelHandler: mockPixelHandler,
agentStopper: mockAgentStopper,
freemiumPIRUserStateManager: mockFreemiumPIRUserState)
freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager)

mockNotificationService.reset()

Expand All @@ -372,7 +372,7 @@ final class DataBrokerProtectionAgentManagerTests: XCTestCase {
operationDependencies: mockDependencies,
pixelHandler: mockPixelHandler,
agentStopper: mockAgentStopper,
freemiumPIRUserStateManager: mockFreemiumPIRUserState)
freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager)

mockNotificationService.reset()

Expand All @@ -394,7 +394,7 @@ final class DataBrokerProtectionAgentManagerTests: XCTestCase {
operationDependencies: mockDependencies,
pixelHandler: mockPixelHandler,
agentStopper: mockAgentStopper,
freemiumPIRUserStateManager: mockFreemiumPIRUserState)
freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager)

mockNotificationService.reset()
mockQueueManager.startImmediateScanOperationsIfPermittedCompletionError = DataBrokerProtectionAgentErrorCollection(oneTimeError: NSError(domain: "test", code: 10))
Expand All @@ -417,7 +417,7 @@ final class DataBrokerProtectionAgentManagerTests: XCTestCase {
operationDependencies: mockDependencies,
pixelHandler: mockPixelHandler,
agentStopper: mockAgentStopper,
freemiumPIRUserStateManager: mockFreemiumPIRUserState)
freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager)

mockNotificationService.reset()
mockDataManager.shouldReturnHasMatches = true
Expand All @@ -440,7 +440,7 @@ final class DataBrokerProtectionAgentManagerTests: XCTestCase {
operationDependencies: mockDependencies,
pixelHandler: mockPixelHandler,
agentStopper: mockAgentStopper,
freemiumPIRUserStateManager: mockFreemiumPIRUserState)
freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager)

mockNotificationService.reset()
mockDataManager.shouldReturnHasMatches = false
Expand All @@ -463,9 +463,9 @@ final class DataBrokerProtectionAgentManagerTests: XCTestCase {
operationDependencies: mockDependencies,
pixelHandler: mockPixelHandler,
agentStopper: mockAgentStopper,
freemiumPIRUserStateManager: mockFreemiumPIRUserState)
freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager)

mockFreemiumPIRUserState.isActiveUser = false
mockFreemiumPIRUserStateManager.isActiveUser = false

var startScheduledScansCalled = false
mockQueueManager.startScheduledAllOperationsIfPermittedCalledCompletion = { _ in
Expand All @@ -490,9 +490,9 @@ final class DataBrokerProtectionAgentManagerTests: XCTestCase {
operationDependencies: mockDependencies,
pixelHandler: mockPixelHandler,
agentStopper: mockAgentStopper,
freemiumPIRUserStateManager: mockFreemiumPIRUserState)
freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager)

mockFreemiumPIRUserState.isActiveUser = true
mockFreemiumPIRUserStateManager.isActiveUser = true

var startScheduledScansCalled = false
mockQueueManager.startScheduledScanOperationsIfPermittedCalledCompletion = { _ in
Expand Down
Loading

0 comments on commit a6c9d8d

Please sign in to comment.