@@ -38,7 +38,7 @@ final class ConnectTests: XCTestCase {
3838 /// This is an example of specifying JSON client params.
3939 /// The test here just ensures that the Kotlin SDK accepts these params and does not crash
4040 try await database. connect (
41- connector: PowerSyncBackendConnector ( ) ,
41+ connector: MockConnector ( ) ,
4242 params: [
4343 " foo " : . string( " bar " ) ,
4444 ]
@@ -50,67 +50,69 @@ final class ConnectTests: XCTestCase {
5050 XCTAssert ( database. currentStatus. connecting == false )
5151
5252 try await database. connect (
53- connector: PowerSyncBackendConnector ( )
53+ connector: MockConnector ( )
5454 )
5555
5656 try await waitFor ( timeout: 10 ) {
5757 guard database. currentStatus. connecting == true else {
5858 throw WaitForMatchError . predicateFail ( message: " Should be connecting " )
5959 }
6060 }
61-
61+
6262 try await database. disconnect ( )
63-
63+
6464 try await waitFor ( timeout: 10 ) {
6565 guard database. currentStatus. connecting == false else {
6666 throw WaitForMatchError . predicateFail ( message: " Should not be connecting after disconnect " )
6767 }
6868 }
6969 }
70-
70+
7171 func testSyncStatusUpdates( ) async throws {
7272 let expectation = XCTestExpectation (
7373 description: " Watch Sync Status "
7474 )
75-
75+
7676 let watchTask = Task { [ database] in
7777 for try await _ in database!. currentStatus. asFlow ( ) {
7878 expectation. fulfill ( )
7979 }
8080 }
81-
81+
8282 // Do some connecting operations
8383 try await database. connect (
84- connector: PowerSyncBackendConnector ( )
84+ connector: MockConnector ( )
8585 )
86-
86+
8787 // We should get an update
8888 await fulfillment ( of: [ expectation] , timeout: 5 )
8989 watchTask. cancel ( )
9090 }
91-
91+
9292 func testSyncHTTPLogs( ) async throws {
9393 let expectation = XCTestExpectation (
9494 description: " Should log a request to the PowerSync endpoint "
9595 )
96-
96+
9797 let fakeUrl = " https://fakepowersyncinstance.fakepowersync.local "
98-
99- class TestConnector : PowerSyncBackendConnector {
98+
99+ final class TestConnector : PowerSyncBackendConnectorProtocol {
100100 let url : String
101-
101+
102102 init ( url: String ) {
103103 self . url = url
104104 }
105-
106- override func fetchCredentials( ) async throws -> PowerSyncCredentials ? {
105+
106+ func fetchCredentials( ) async throws -> PowerSyncCredentials ? {
107107 PowerSyncCredentials (
108108 endpoint: url,
109109 token: " 123 "
110110 )
111111 }
112+
113+ func uploadData( database _: PowerSyncDatabaseProtocol ) async throws { }
112114 }
113-
115+
114116 try await database. connect (
115117 connector: TestConnector ( url: fakeUrl) ,
116118 options: ConnectOptions (
@@ -126,9 +128,9 @@ final class ConnectTests: XCTestCase {
126128 )
127129 )
128130 )
129-
131+
130132 await fulfillment ( of: [ expectation] , timeout: 5 )
131-
133+
132134 try await database. disconnectAndClear ( )
133135 }
134136}
0 commit comments