Skip to content

Commit eaef06d

Browse files
committed
Manual integration test for sync progress.
1 parent e41617e commit eaef06d

File tree

3 files changed

+60
-2
lines changed

3 files changed

+60
-2
lines changed

PowerSync/PowerSync.Common/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
- Add `trackPreviousValues` option on `TableOptions` which sets `CrudEntry.PreviousValues` to previous values on updates.
55
- Add `trackMetadata` option on `TableOptions` which adds a `_metadata` column that can be used for updates. The configured metadata is available through `CrudEntry.Metadata`.
66
- Add `ignoreEmptyUpdates` option on `TableOptions` which skips creating CRUD entries for updates that don't change any values.
7-
7+
- Report progress information about downloaded rows. Sync progress is available through `SyncStatus.DownloadProgress()`.
88

99
## 0.0.5-alpha.1
1010
- Using the latest (0.4.9) version of the core extension, it introduces support for the Rust Sync implementation and also makes it the default - users can still opt out and use the legacy C# sync implementation as option when calling `connect()`.

PowerSync/PowerSync.Common/DB/Crud/SyncProgress.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public class ProgressWithOperations
6868
public int TotalOperations { get; set; }
6969

7070
/// <summary>
71-
/// The numnber of operations that have already been downloaded.
71+
/// The number of operations that have already been downloaded.
7272
/// </summary>
7373
public int DownloadedOperations { get; set; }
7474

Tests/PowerSync/PowerSync.Common.IntegrationTests/SyncIntegrationTests.cs

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,66 @@ await db.Execute("insert into lists (id, name, owner_id, created_at) values (uui
218218
await backendInsertWatch.Task;
219219
}
220220

221+
222+
/// <summary>
223+
/// Helper that requires manual setup of the data to verify that download progress updates are working.
224+
/// Ensure backend has 5000+ entries, then run this test to see progress updates in the console.
225+
/// </summary>
226+
// [IntegrationFact(Timeout = 10000)]
227+
// public async Task InitialSyncDownloadProgressTest()
228+
// {
229+
// ILoggerFactory loggerFactory = LoggerFactory.Create(builder =>
230+
// {
231+
// builder.AddConsole();
232+
// builder.SetMinimumLevel(LogLevel.Information);
233+
// });
234+
235+
// var logger = loggerFactory.CreateLogger("PowerSyncLogger");
236+
237+
// nodeClient = new NodeClient(userId);
238+
// db = new PowerSyncDatabase(new PowerSyncDatabaseOptions
239+
// {
240+
// Database = new SQLOpenOptions { DbFilename = "powersync-sync-progress-tests.db" },
241+
// Schema = TestSchema.PowerSyncSchema,
242+
// Logger = logger
243+
244+
// });
245+
// await db.Init();
246+
// await db.DisconnectAndClear();
247+
248+
249+
// var clearListener = db.RunListener((update) =>
250+
// {
251+
// if (update.StatusChanged != null)
252+
// {
253+
// try
254+
// {
255+
// Console.WriteLine("Total: " + update.StatusChanged.DownloadProgress()?.TotalOperations + " Downloaded: " + update.StatusChanged.DownloadProgress()?.DownloadedOperations);
256+
// Console.WriteLine("Synced: " + Math.Round((decimal)(update.StatusChanged.DownloadProgress()?.DownloadedFraction * 100)) + "%");
257+
258+
// }
259+
// catch (Exception ex)
260+
// {
261+
// Console.WriteLine("Exception reading DownloadProgress: " + ex);
262+
// }
263+
// }
264+
// });
265+
266+
// var connector = new NodeConnector(userId);
267+
// await db.Connect(connector);
268+
// await db.WaitForFirstSync();
269+
270+
// clearListener.Dispose();
271+
// await db.DisconnectAndClear();
272+
// await db.Close();
273+
// }
274+
221275
private async Task ClearAllData()
222276
{
277+
if (db.Closed)
278+
{
279+
return;
280+
}
223281
// Inefficient but simple way to clear all data, avoiding payload limitations
224282
var results = await db.GetAll<ListResult>("select * from lists");
225283
foreach (var item in results)

0 commit comments

Comments
 (0)