-
Notifications
You must be signed in to change notification settings - Fork 29
[Feature] Add warning if crud transactions are not completed #172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5010b88
Show warning if crud transactions are not completed
mugikhan b492be8
Test on native for upload tests
mugikhan d267563
Fix crudMutex and uploading status
mugikhan 3a75258
Merge branch 'main' into feat/crud-transactions-warning
mugikhan 29c7431
Add back retry delay for crudMutex
mugikhan 8f74f9c
Merge branch 'main' into feat/crud-transactions-warning
mugikhan f045ba8
chore(release): publish packages
mugikhan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.