@@ -51,23 +51,24 @@ struct RemoteInterfaceExtensionTests {
5151 await RetrievedCapabilitiesActor . shared. reset ( )
5252
5353 let ( fetchedCaps, fetchedData) = capabilitiesFromMockJSON ( )
54- var fetcherCalled = false
5554 var remoteInterface = TestableRemoteInterface ( )
56- remoteInterface. fetchCapabilitiesHandler = { acc, _, _ in
57- fetcherCalled = true
58- #expect( acc. ncKitAccount == testAccount. ncKitAccount)
59- return ( acc. ncKitAccount, fetchedCaps, fetchedData, . success)
55+
56+ await confirmation ( " fetcherCalled " ) { fetcherCalled in
57+ remoteInterface. fetchCapabilitiesHandler = { acc, _, _ in
58+ fetcherCalled ( )
59+ #expect( acc. ncKitAccount == testAccount. ncKitAccount)
60+ return ( acc. ncKitAccount, fetchedCaps, fetchedData, . success)
61+ }
6062 }
6163
6264 let result = await remoteInterface. currentCapabilities ( account: testAccount)
6365
64- #expect( fetcherCalled, " fetchCapabilities should be called when cache is empty. " )
6566 #expect( result. error == . success)
6667 #expect( result. capabilities == fetchedCaps)
6768 #expect( result. data == fetchedData)
6869
69- let actorCache = await RetrievedCapabilitiesActor . shared. data
70- #expect( actorCache [ testAccount . ncKitAccount ] ? . capabilities == fetchedCaps)
70+ let actorCache = await RetrievedCapabilitiesActor . shared. getCapabilities ( for : testAccount . ncKitAccount )
71+ #expect( actorCache? . capabilities == fetchedCaps)
7172 }
7273
7374 @Test func currentCapabilitiesFetchesOnStaleCache( ) async throws {
@@ -101,23 +102,25 @@ struct RemoteInterfaceExtensionTests {
101102 )
102103
103104 let ( newCaps, newData) = capabilitiesFromMockJSON ( ) // Fresh data to be fetched
104- var fetcherCalled = false
105+
105106 var remoteInterface = TestableRemoteInterface ( )
106- remoteInterface. fetchCapabilitiesHandler = { acc, _, _ in
107- fetcherCalled = true
108- return ( acc. ncKitAccount, newCaps, newData, . success)
107+
108+ await confirmation ( " fetcherCalled " ) { fetcherCalled in
109+ remoteInterface. fetchCapabilitiesHandler = { acc, _, _ in
110+ fetcherCalled ( )
111+ return ( acc. ncKitAccount, newCaps, newData, . success)
112+ }
109113 }
110114
111115 let result = await remoteInterface. currentCapabilities ( account: testAccount)
112116
113- #expect( fetcherCalled, " fetchCapabilities should be called for stale cache. " )
114117 #expect( result. error == . success)
115118 #expect( result. capabilities == newCaps, " Should return newly fetched capabilities. " )
116119 #expect( result. data == newData)
117120
118- let actorCache = await RetrievedCapabilitiesActor . shared. data
119- #expect( actorCache [ testAccount . ncKitAccount ] ? . capabilities == newCaps)
120- #expect( ( actorCache [ testAccount . ncKitAccount ] ? . retrievedAt ?? . distantPast) > staleDate)
121+ let actorCache = await RetrievedCapabilitiesActor . shared. getCapabilities ( for : testAccount . ncKitAccount )
122+ #expect( actorCache? . capabilities == newCaps)
123+ #expect( ( actorCache? . retrievedAt ?? . distantPast) > staleDate)
121124 }
122125
123126 @Test func currentCapabilitiesAwaitsAndUsesCache( ) async throws {
0 commit comments