Skip to content

Commit

Permalink
Remove MockDependencyProvider (#3456)
Browse files Browse the repository at this point in the history
Task/Issue URL: https://app.asana.com/0/414235014887631/1208580381705388/f
Tech Design URL:
CC:

Description:

This PR removes MockDependencyProvider and the ability to create testing instances of AppDependencyProvider. Any test files that use it have been updated to take their dependencies directly.

The only tests affected by this change are subscription ones; DownloadManagerTests had a mock dependency provider property, but it didn't appear to be used in any way.
  • Loading branch information
samsymons authored Oct 21, 2024
1 parent 29e974f commit de78c05
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 105 deletions.
4 changes: 0 additions & 4 deletions DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,6 @@
98B001AA251EABB40090EC07 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 98B001A8251EABB40090EC07 /* Localizable.strings */; };
98B001B0251EABB40090EC07 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 98B001AE251EABB40090EC07 /* InfoPlist.strings */; };
98B001B3251EABB40090EC07 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 98B001B1251EABB40090EC07 /* InfoPlist.strings */; };
98B31290218CCB2200E54DE1 /* MockDependencyProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98B3128F218CCB2200E54DE1 /* MockDependencyProvider.swift */; };
98B31292218CCB8C00E54DE1 /* AppDependencyProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98B31291218CCB8C00E54DE1 /* AppDependencyProvider.swift */; };
98BFA911294A2086004EA636 /* bookmarks_3k.html in Resources */ = {isa = PBXBuildFile; fileRef = 98BFA910294A2086004EA636 /* bookmarks_3k.html */; };
98BFA913294A3DDC004EA636 /* BookmarksEditModelPerformanceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98BFA912294A3DDC004EA636 /* BookmarksEditModelPerformanceTests.swift */; };
Expand Down Expand Up @@ -2454,7 +2453,6 @@
98B12739251EABD5007473E4 /* el */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = el; path = el.lproj/InfoPlist.strings; sourceTree = "<group>"; };
98B1273B251EABD5007473E4 /* el */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = el; path = el.lproj/InfoPlist.strings; sourceTree = "<group>"; };
98B1273C251EABD5007473E4 /* el */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = el; path = el.lproj/Localizable.strings; sourceTree = "<group>"; };
98B3128F218CCB2200E54DE1 /* MockDependencyProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockDependencyProvider.swift; sourceTree = "<group>"; };
98B31291218CCB8C00E54DE1 /* AppDependencyProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDependencyProvider.swift; sourceTree = "<group>"; };
98B4904D251EAC2200A1B398 /* pl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = pl; path = pl.lproj/InfoPlist.strings; sourceTree = "<group>"; };
98B4904E251EAC2200A1B398 /* pl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = pl; path = pl.lproj/InfoPlist.strings; sourceTree = "<group>"; };
Expand Down Expand Up @@ -5986,7 +5984,6 @@
children = (
9F4CC51A2C48C0C7006A96EB /* MockTabDelegate.swift */,
C14882E927F20DD000D59F0C /* MockBookmarksCoreDataStorage.swift */,
98B3128F218CCB2200E54DE1 /* MockDependencyProvider.swift */,
C158AC7A297AB5DC0008723A /* MockSecureVault.swift */,
F1134EBA1F40D3D000B73467 /* MockStatisticsStore.swift */,
026DABA328242BC80089E0B5 /* MockUserAgent.swift */,
Expand Down Expand Up @@ -7934,7 +7931,6 @@
F13B4BF91F18CA0600814661 /* TabsModelTests.swift in Sources */,
F1BDDBFD2C340D9C00459306 /* SubscriptionContainerViewModelTests.swift in Sources */,
987243142C5232B5007ECC76 /* BookmarksDatabaseSetupTests.swift in Sources */,
98B31290218CCB2200E54DE1 /* MockDependencyProvider.swift in Sources */,
CBDD5DDF29A6736A00832877 /* APIHeadersTests.swift in Sources */,
D6F557BA2C8859040034444B /* DuckPlayerExperimentTests.swift in Sources */,
986B45D0299E30A50089D2D7 /* BookmarkEntityTests.swift in Sources */,
Expand Down
5 changes: 0 additions & 5 deletions DuckDuckGo/AppDependencyProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,4 @@ final class AppDependencyProvider: DependencyProvider {
accountManager: accountManager)
}

/// Only meant to be used for testing.
///
static func makeTestingInstance() -> Self {
Self.init()
}
}
2 changes: 0 additions & 2 deletions DuckDuckGoTests/DownloadManagerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ import WidgetKit
class DownloadManagerTests: XCTestCase {
private let downloadManagerTestsHelper = DownloadTestsHelper(downloadsDirectory: DownloadManager().downloadsDirectory)

var mockDependencyProvider: MockDependencyProvider!

override func tearDown() {
super.tearDown()
downloadManagerTestsHelper.deleteAllFiles()
Expand Down
92 changes: 0 additions & 92 deletions DuckDuckGoTests/MockDependencyProvider.swift

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,21 @@ import SubscriptionTestingUtilities

final class SubscriptionContainerViewModelTests: XCTestCase {
var sut: SubscriptionContainerViewModel!
let subscriptionManager = MockDependencyProvider().subscriptionManager

let subscriptionManager: SubscriptionManager = {
let accountManager = AccountManagerMock()
let subscriptionService = SubscriptionEndpointServiceMock()
let authService = AuthEndpointServiceMock()
let storePurchaseManager = StorePurchaseManagerMock()
return SubscriptionManagerMock(accountManager: accountManager,
subscriptionEndpointService: subscriptionService,
authEndpointService: authService,
storePurchaseManager: storePurchaseManager,
currentEnvironment: SubscriptionEnvironment(serviceEnvironment: .production,
purchasePlatform: .appStore),
canPurchase: true)
}()

let subscriptionFeatureAvailability = SubscriptionFeatureAvailabilityMock.enabled

func testWhenInitWithOriginThenSubscriptionFlowPurchaseURLHasOriginSet() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,20 @@ import SubscriptionTestingUtilities
final class SubscriptionFlowViewModelTests: XCTestCase {
private var sut: SubscriptionFlowViewModel!

let subscriptionManager = MockDependencyProvider().subscriptionManager
let subscriptionManager: SubscriptionManager = {
let accountManager = AccountManagerMock()
let subscriptionService = DefaultSubscriptionEndpointService(currentServiceEnvironment: .production)
let authService = DefaultAuthEndpointService(currentServiceEnvironment: .production)
let storePurchaseManager = DefaultStorePurchaseManager()
return SubscriptionManagerMock(accountManager: accountManager,
subscriptionEndpointService: subscriptionService,
authEndpointService: authService,
storePurchaseManager: storePurchaseManager,
currentEnvironment: SubscriptionEnvironment(serviceEnvironment: .production,
purchasePlatform: .appStore),
canPurchase: true)
}()

let subscriptionFeatureAvailability = SubscriptionFeatureAvailabilityMock.enabled

func testWhenInitWithOriginThenSubscriptionFlowPurchaseURLHasOriginSet() {
Expand Down

0 comments on commit de78c05

Please sign in to comment.