MockProfiles.swift (738B)
1 // 2 // MockProfiles.swift 3 // damusTests 4 // 5 // Created by Daniel D’Aquino on 2023-10-13. 6 // 7 8 import Foundation 9 @testable import damus 10 11 // A Mockable `Profiles` class that can be used for testing. 12 // Note: Not all methods are mocked. You might need to implement a method depending on the test you are writing. 13 class MockProfiles: Profiles { 14 var mocked_profiles: [Pubkey: Profile] = [:] 15 var ndb: Ndb 16 17 init?(mocked_profiles: [Pubkey : Profile], ndb: Ndb) { 18 self.mocked_profiles = mocked_profiles 19 self.ndb = ndb 20 super.init(ndb: ndb) 21 } 22 23 func lookup(id: Pubkey) -> NdbTxn<Profile?>? { 24 return NdbTxn(ndb: self.ndb) { txn in 25 return self.mocked_profiles[id] 26 } 27 } 28 }