Skip to content

Commit

Permalink
PIR: Bump v3 Database Migration to 100% (#3102)
Browse files Browse the repository at this point in the history
Task/Issue URL:
https://app.asana.com/0/1206488453854252/1207806240565841/f

**Description**: Bumps v3 migration rollout by completely removing
`DataBrokerProtectionMigrationsFeatureFlagger` and related tests.
  • Loading branch information
aataraxiaa authored Aug 15, 2024
1 parent deaa83e commit 40bf3cd
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 305 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ protocol DataBrokerProtectionDatabaseProvider: SecureStorageDatabaseProvider {

final class DefaultDataBrokerProtectionDatabaseProvider: GRDBSecureStorageDatabaseProvider, DataBrokerProtectionDatabaseProvider {

typealias FeatureFlagger = DataBrokerProtectionMigrationsFeatureFlagger
typealias MigrationsProvider = DataBrokerProtectionDatabaseMigrationsProvider

public static func defaultDatabaseURL() -> URL {
Expand All @@ -94,14 +93,8 @@ final class DefaultDataBrokerProtectionDatabaseProvider: GRDBSecureStorageDataba
/// - Returns: DefaultDataBrokerProtectionDatabaseProvider instance
public static func create<T: MigrationsProvider>(file: URL = DefaultDataBrokerProtectionDatabaseProvider.defaultDatabaseURL(),
key: Data,
featureFlagger: FeatureFlagger = DefaultDataBrokerProtectionMigrationsFeatureFlagger(),
migrationProvider: T.Type = DefaultDataBrokerProtectionDatabaseMigrationsProvider.self) throws -> DefaultDataBrokerProtectionDatabaseProvider {

if featureFlagger.isUserIn(percent: 10) {
return try DefaultDataBrokerProtectionDatabaseProvider(file: file, key: key, registerMigrationsHandler: migrationProvider.v3Migrations)
} else {
return try DefaultDataBrokerProtectionDatabaseProvider(file: file, key: key, registerMigrationsHandler: migrationProvider.v2Migrations)
}
try DefaultDataBrokerProtectionDatabaseProvider(file: file, key: key, registerMigrationsHandler: migrationProvider.v3Migrations)
}

public init(file: URL = DefaultDataBrokerProtectionDatabaseProvider.defaultDatabaseURL(),
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -216,30 +216,6 @@ final class DataBrokerProtectionDatabaseProviderTests: XCTestCase {
XCTAssertNoThrow(try sut.deleteProfileData())
XCTAssertTrue(try sut.db.allTablesAreEmpty())
}

func testCreationWithUserNotIn10PercentUsesV2Migrations() throws {
// Given
let mockFeatureFlagger = MockFeatureFlagger(isUserIn: false)

// When
_ = try DefaultDataBrokerProtectionDatabaseProvider.create(file: vaultURL, key: key, featureFlagger: mockFeatureFlagger, migrationProvider: MockMigrationsProvider.self)

// Then
XCTAssertTrue(MockMigrationsProvider.didCallV2Migrations)
XCTAssertFalse(MockMigrationsProvider.didCallV3Migrations)
}

func testCreationWithUserIn10PercentUsesV3Migrations() throws {
// Given
let mockFeatureFlagger = MockFeatureFlagger(isUserIn: true)

// When
_ = try DefaultDataBrokerProtectionDatabaseProvider.create(file: vaultURL, key: key, featureFlagger: mockFeatureFlagger, migrationProvider: MockMigrationsProvider.self)

// Then
XCTAssertFalse(MockMigrationsProvider.didCallV2Migrations)
XCTAssertTrue(MockMigrationsProvider.didCallV3Migrations)
}
}

private extension DatabaseWriter {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -1744,11 +1744,3 @@ struct MockMigrationsProvider: DataBrokerProtectionDatabaseMigrationsProvider {
return { _ in }
}
}

struct MockFeatureFlagger: DataBrokerProtectionMigrationsFeatureFlagger {
var isUserIn = false

func isUserIn(percent: Int) -> Bool {
isUserIn
}
}

0 comments on commit 40bf3cd

Please sign in to comment.