1
0
mirror of git://jb55.com/damus synced 2024-10-06 11:43:21 +00:00

add damus_donation to profile data model and update tests

This commit is contained in:
Bryan Montz 2023-05-26 07:02:14 -05:00
parent ea73c5252d
commit e10dc93233
4 changed files with 9 additions and 3 deletions

View File

@ -1,8 +1,9 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="21513" systemVersion="22E261" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="21754" systemVersion="22E261" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
<entity name="PersistedProfile" representedClassName="PersistedProfile" syncable="YES">
<attribute name="about" optional="YES" attributeType="String"/>
<attribute name="banner" optional="YES" attributeType="String"/>
<attribute name="damus_donation" optional="YES" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="YES"/>
<attribute name="display_name" optional="YES" attributeType="String"/>
<attribute name="id" optional="YES" attributeType="String"/>
<attribute name="last_update" optional="YES" attributeType="Date" usesScalarValueType="NO"/>

View File

@ -20,6 +20,7 @@ final class PersistedProfile: NSManagedObject {
@NSManaged var lud06: String?
@NSManaged var lud16: String?
@NSManaged var nip05: String?
@NSManaged var damus_donation: Int16
@NSManaged var last_update: Date? // The date that the profile was last updated by the user
@NSManaged var network_pull_date: Date? // The date we got this profile from a relay (for staleness checking)
@ -33,5 +34,6 @@ final class PersistedProfile: NSManagedObject {
lud06 = profile.lud06
lud16 = profile.lud16
nip05 = profile.nip05
damus_donation = profile.damus_donation != nil ? Int16(profile.damus_donation!) : 0
}
}

View File

@ -33,7 +33,8 @@ class Profile: Codable {
website: persisted_profile.website,
lud06: persisted_profile.lud06,
lud16: persisted_profile.lud16,
nip05: persisted_profile.nip05)
nip05: persisted_profile.nip05,
damus_donation: Int(persisted_profile.damus_donation))
}
private func str(_ str: String) -> String? {

View File

@ -27,7 +27,8 @@ class ProfileDatabaseTests: XCTestCase {
website: "test-website",
lud06: "test-lud06",
lud16: "test-lud16",
nip05: "test-nip05")
nip05: "test-nip05",
damus_donation: 100)
}
func testStoreAndRetrieveProfile() async throws {
@ -53,6 +54,7 @@ class ProfileDatabaseTests: XCTestCase {
XCTAssertEqual(profile.lud06, retrievedProfile.lud06)
XCTAssertEqual(profile.lud16, retrievedProfile.lud16)
XCTAssertEqual(profile.nip05, retrievedProfile.nip05)
XCTAssertEqual(profile.damus_donation, retrievedProfile.damus_donation)
}
func testRejectOutdatedProfile() async throws {