import 'dart:io'; import 'package:flutter_test/flutter_test.dart'; import 'package:mews/application/key_store.dart'; void main() { late Directory dir; late KeyStore keys; setUp(() async { dir = await Directory.systemTemp.createTemp('mews-keys'); keys = KeyStore(() async => dir); }); tearDown(() { dir.deleteSync(recursive: true); }); test('a key is stored, read back and removed', () async { expect(await keys.read(7), isNull); await keys.save(7, 'KEY PEM'); expect(await keys.read(7), 'KEY PEM'); // Saving again replaces, the way a renewed identity replaces its key. await keys.save(7, 'NEW KEY PEM'); expect(await keys.read(7), 'NEW KEY PEM'); await keys.delete(7); expect(await keys.read(7), isNull); }); }