Skip to content

Commit 8759d66

Browse files
remove fixme. Add unit tests
1 parent caa1ad9 commit 8759d66

File tree

2 files changed

+37
-22
lines changed

2 files changed

+37
-22
lines changed

packages/powersync_core/lib/src/sync/streaming_sync.dart

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -775,27 +775,7 @@ final class _ActiveRustStreamingIteration {
775775
},
776776
line);
777777
case EstablishSyncStream(:final request):
778-
// FIXME
779-
// Merge app_metadata from options into the instruction request
780-
// since the Rust instruction does not yet merge app_metadata from the supplied options.
781-
// Rust client values will override options values if present.
782-
final mergedRequest = Map<String, Object?>.from(request);
783-
final appMetadata = sync.options.appMetadata;
784-
if (appMetadata.isNotEmpty) {
785-
final existingMetadata = request['app_metadata'];
786-
if (existingMetadata is Map) {
787-
// Merge: start with options, then let Rust override
788-
mergedRequest['app_metadata'] = {
789-
...appMetadata,
790-
...existingMetadata.cast<String, String>(),
791-
};
792-
} else {
793-
// No existing metadata, just use options
794-
mergedRequest['app_metadata'] = appMetadata;
795-
}
796-
}
797-
_completedStream
798-
.complete(_handleLines(EstablishSyncStream(mergedRequest)));
778+
_completedStream.complete(_handleLines(EstablishSyncStream(request)));
799779
case UpdateSyncStatus(:final status):
800780
sync._state.updateStatus((m) => m.applyFromCore(status));
801781
case FetchCredentials(:final didExpire):

packages/powersync_core/test/sync/stream_test.dart

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import 'dart:convert';
44
import 'package:async/async.dart';
55
import 'package:logging/logging.dart';
66
import 'package:powersync_core/powersync_core.dart';
7-
87
import 'package:test/test.dart';
98

109
import '../server/sync_server/in_memory_sync_server.dart';
@@ -260,4 +259,40 @@ void main() {
260259
);
261260
a.unsubscribe();
262261
});
262+
263+
test('passes app metadata to the server (rust)', () async {
264+
options = SyncOptions(
265+
syncImplementation: SyncClientImplementation.rust,
266+
appMetadata: {'foo': 'bar'},
267+
);
268+
269+
await waitForConnection();
270+
271+
final request = await syncService.waitForListener;
272+
expect(
273+
json.decode(await request.readAsString()),
274+
containsPair(
275+
'app_metadata',
276+
containsPair('foo', 'bar'),
277+
),
278+
);
279+
});
280+
281+
test('passes app metadata to the server (legacy sync client)', () async {
282+
options = SyncOptions(
283+
syncImplementation: SyncClientImplementation.dart,
284+
appMetadata: {'foo': 'bar'},
285+
);
286+
287+
await waitForConnection();
288+
289+
final request = await syncService.waitForListener;
290+
expect(
291+
json.decode(await request.readAsString()),
292+
containsPair(
293+
'app_metadata',
294+
containsPair('foo', 'bar'),
295+
),
296+
);
297+
});
263298
}

0 commit comments

Comments
 (0)