applyYamlTestStorageBootstrap function
Implementation
Future<void> applyYamlTestStorageBootstrap(EnsembleTestSetup setup) async {
for (final entry in setup.initialPublicStorage?.entries ??
const Iterable<MapEntry<String, dynamic>>.empty()) {
await StorageManager().write(entry.key, entry.value);
}
for (final entry in setup.initialSecureStorage?.entries ??
const Iterable<MapEntry<String, dynamic>>.empty()) {
EncryptedStorageManager.setSecureStorage({
'key': entry.key,
'value': entry.value,
});
// The runtime API is synchronous for compatibility with released
// Ensemble versions, while GetStorage persists asynchronously. Wait for
// the backend entry to become observable before mounting the app.
for (var attempt = 0; attempt < 50; attempt++) {
if (StorageManager().read('enc_${entry.key}') != null) break;
await Future<void>.delayed(const Duration(milliseconds: 10));
}
}
for (final entry in setup.initialKeychain?.entries ??
const Iterable<MapEntry<String, dynamic>>.empty()) {
await StorageManager().writeSecurely(key: entry.key, value: entry.value);
}
}