mirror of
https://github.com/jonasbark/swiftcontrol.git
synced 2026-11-30 09:42:48 +01:00
Microsoft Store sync: don't send an empty collections ID key
The Store returns an empty string, not an error, when it can't make one (seen on an unpackaged Windows build). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -46,6 +46,9 @@ class MsStoreCollectionsSync {
|
||||
serviceTicket: ticket.serviceTicket,
|
||||
publisherUserId: ticket.publisherUserId,
|
||||
);
|
||||
// The Store answers an empty key instead of an error when it can't
|
||||
// make one (e.g. an unpackaged build).
|
||||
if (key.isEmpty) throw StateError('Microsoft Store returned no collections ID key');
|
||||
final base = await submitKey(key);
|
||||
if (base != 'none') await writeFlag(_flagFor(userId), base);
|
||||
await refreshEntitlements();
|
||||
|
||||
@@ -74,4 +74,24 @@ void main() {
|
||||
await sync.sync();
|
||||
expect(errors.single, isA<StateError>());
|
||||
});
|
||||
|
||||
test('an empty Store key (unpackaged build, Store unavailable) is never sent', () async {
|
||||
final errors = <Object>[];
|
||||
final sync = MsStoreCollectionsSync(
|
||||
currentUserId: () => 'user-1',
|
||||
requestTicket: () async => (serviceTicket: 'T', publisherUserId: 'user-1'),
|
||||
collectionsIdKey: ({required serviceTicket, required publisherUserId}) async => '',
|
||||
submitKey: (_) async {
|
||||
calls.add('sync');
|
||||
return 'active';
|
||||
},
|
||||
refreshEntitlements: () async {},
|
||||
readFlag: (_) async => null,
|
||||
writeFlag: (_, _) async {},
|
||||
onError: (e, s) => errors.add(e),
|
||||
);
|
||||
await sync.sync();
|
||||
expect(calls, isEmpty);
|
||||
expect(errors.single, isA<StateError>());
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user