-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature] Add warning if crud transactions are not completed (#172)
* Show warning if crud transactions are not completed * Test on native for upload tests * Fix crudMutex and uploading status * Add back retry delay for crudMutex * chore(release): publish packages - powersync@1.8.4 - powersync_attachments_helper@0.6.8
- Loading branch information
Showing
18 changed files
with
200 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
const String libraryVersion = '1.8.3'; | ||
const String libraryVersion = '1.8.4'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
@TestOn('!browser') | ||
|
||
import 'package:powersync/powersync.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
import 'test_server.dart'; | ||
import 'utils/abstract_test_utils.dart'; | ||
import 'utils/test_utils_impl.dart'; | ||
|
||
final testUtils = TestUtils(); | ||
const testId = "2290de4f-0488-4e50-abed-f8e8eb1d0b42"; | ||
const testId2 = "2290de4f-0488-4e50-abed-f8e8eb1d0b43"; | ||
const partialWarning = | ||
'Potentially previously uploaded CRUD entries are still present'; | ||
|
||
class TestConnector extends PowerSyncBackendConnector { | ||
final Function _fetchCredentials; | ||
final Future<void> Function(PowerSyncDatabase database) _uploadData; | ||
|
||
TestConnector(this._fetchCredentials, this._uploadData); | ||
|
||
@override | ||
Future<PowerSyncCredentials?> fetchCredentials() { | ||
return _fetchCredentials(); | ||
} | ||
|
||
@override | ||
Future<void> uploadData(PowerSyncDatabase database) async { | ||
return _uploadData(database); | ||
} | ||
} | ||
|
||
void main() { | ||
group('CRUD Tests', () { | ||
late PowerSyncDatabase powersync; | ||
late String path; | ||
|
||
setUp(() async { | ||
path = testUtils.dbPath(); | ||
await testUtils.cleanDb(path: path); | ||
}); | ||
|
||
tearDown(() async { | ||
// await powersync.disconnectAndClear(); | ||
await powersync.close(); | ||
}); | ||
|
||
test('should warn for missing upload operations in uploadData', () async { | ||
var server = await createServer(); | ||
|
||
credentialsCallback() async { | ||
return PowerSyncCredentials( | ||
endpoint: server.endpoint, | ||
token: 'token', | ||
userId: 'userId', | ||
); | ||
} | ||
|
||
uploadData(PowerSyncDatabase db) async { | ||
// Do nothing | ||
} | ||
|
||
final records = <String>[]; | ||
final sub = | ||
testWarningLogger.onRecord.listen((log) => records.add(log.message)); | ||
|
||
powersync = | ||
await testUtils.setupPowerSync(path: path, logger: testWarningLogger); | ||
powersync.retryDelay = Duration(milliseconds: 0); | ||
var connector = TestConnector(credentialsCallback, uploadData); | ||
powersync.connect(connector: connector); | ||
|
||
// Create something with CRUD in it. | ||
await powersync.execute( | ||
'INSERT INTO assets(id, description) VALUES(?, ?)', [testId, 'test']); | ||
|
||
// Wait for the uploadData to be called. | ||
await Future.delayed(Duration(milliseconds: 100)); | ||
|
||
// Create something else with CRUD in it. | ||
await powersync.execute( | ||
'INSERT INTO assets(id, description) VALUES(?, ?)', | ||
[testId2, 'test2']); | ||
|
||
sub.cancel(); | ||
|
||
expect(records, hasLength(2)); | ||
expect(records, anyElement(contains(partialWarning))); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
## 0.6.8 | ||
|
||
- Update a dependency to the latest release. | ||
|
||
## 0.6.7 | ||
|
||
- Update a dependency to the latest release. | ||
|
Oops, something went wrong.