Finish up migration test.
This commit is contained in:
parent
45a71181d1
commit
1adc5ce11e
|
@ -36,6 +36,8 @@ public class LK001UpdateFriendRequestStatusStorage: OWSDatabaseMigration {
|
|||
OWSPrimaryStorage.shared().setFriendRequestStatus(friendRequestStatus, for: thread.contactIdentifier(), transaction: transaction)
|
||||
}
|
||||
}
|
||||
|
||||
completion()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,44 @@ class LK001UpdateFriendRequestStatusStorageTest : XCTestCase {
|
|||
}
|
||||
|
||||
func test_shouldMigrateFriendRequestStatusCorrectly() {
|
||||
typealias ThreadFriendRequestStatus = NSInteger
|
||||
let friendRequestMappings: [ThreadFriendRequestStatus: LKFriendRequestStatus] = [
|
||||
0: .none,
|
||||
1: .requestSending,
|
||||
2: .requestSent,
|
||||
3: .requestReceived,
|
||||
4: .friends,
|
||||
5: .requestExpired
|
||||
];
|
||||
|
||||
var hexEncodedPublicKeyMapping: [String: ThreadFriendRequestStatus] = [:]
|
||||
for (threadFriendRequestStatus, _) in friendRequestMappings {
|
||||
let hexEncodedPublicKey = Curve25519.generateKeyPair().hexEncodedPublicKey
|
||||
hexEncodedPublicKeyMapping[hexEncodedPublicKey] = threadFriendRequestStatus
|
||||
}
|
||||
|
||||
storage.dbReadWriteConnection.readWrite { transaction in
|
||||
for (hexEncodedPublicKey, friendRequestStatus) in hexEncodedPublicKeyMapping {
|
||||
let thread = TSContactThread.getOrCreateThread(withContactId: hexEncodedPublicKey, transaction: transaction)
|
||||
thread.friendRequestStatus = friendRequestStatus
|
||||
thread.save(with: transaction)
|
||||
}
|
||||
}
|
||||
|
||||
// Wait for migration to complete
|
||||
let migration = self.expectation(description: "Migration")
|
||||
LK001UpdateFriendRequestStatusStorage().runUp {
|
||||
migration.fulfill()
|
||||
}
|
||||
self.wait(for: [migration], timeout: 5.0)
|
||||
|
||||
storage.dbReadWriteConnection.readWrite { transaction in
|
||||
for (hexEncodedPublicKey, threadFriendRequestStatus) in hexEncodedPublicKeyMapping {
|
||||
let expectedFriendRequestStatus = friendRequestMappings[threadFriendRequestStatus]!
|
||||
let friendRequestStatus = self.storage.getFriendRequestStatus(for: hexEncodedPublicKey, transaction: transaction)
|
||||
XCTAssertEqual(friendRequestStatus, expectedFriendRequestStatus, "Expected friend request status \(friendRequestStatus.rawValue) to match \(expectedFriendRequestStatus.rawValue)")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -40,7 +40,6 @@ extern const NSUInteger kOWSProfileManager_MaxAvatarDiameter;
|
|||
- (nullable UIImage *)localProfileAvatarImage;
|
||||
- (nullable NSData *)localProfileAvatarData;
|
||||
- (nullable NSString *)profilePictureURL;
|
||||
- (void)ensureLocalProfileCached;
|
||||
|
||||
// This method is used to update the "local profile" state on the client
|
||||
// and the service. Client state is only updated if service state is
|
||||
|
|
|
@ -35,6 +35,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
- (void)updateProfileForContactWithID:(NSString *)contactID displayName:(NSString *)displayName with:(YapDatabaseReadWriteTransaction *)transaction;
|
||||
- (void)updateServiceWithProfileName:(nullable NSString *)localProfileName avatarURL:(nullable NSString *)avatarURL;
|
||||
|
||||
- (void)ensureLocalProfileCached;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
|
|
@ -90,6 +90,11 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
// Do nothing.
|
||||
}
|
||||
|
||||
- (void)ensureLocalProfileCached
|
||||
{
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue