Commit 87bc19b

derdilla <82763757+NobodyForNothing@users.noreply.github.com>
2024-03-29 09:33:34
test health data dstore
Signed-off-by: derdilla <82763757+NobodyForNothing@users.noreply.github.com>
1 parent 321e602
Changed files (1)
health_data_store
health_data_store/test/src/health_data_store_test.dart
@@ -4,6 +4,7 @@ import 'package:test/expect.dart';
 import 'package:test/scaffolding.dart';
 
 import 'database_manager_test.dart';
+import 'types/blood_pressure_record_test.dart';
 
 void main() {
  sqfliteTestInit();
@@ -12,5 +13,27 @@ void main() {
     await openDatabase(inMemoryDatabasePath));
   expect(store, isNotNull);
  });
- // TODO: implement more tests
+ test('should construct repositories', () async {
+  final store = await HealthDataStore.load(
+      await openDatabase(inMemoryDatabasePath));
+  expect(store, isNotNull);
+  expect(() => store!.medRepo, returnsNormally);
+  expect(() => store!.intakeRepo, returnsNormally);
+  expect(() => store!.bpRepo, returnsNormally);
+  expect(() => store!.noteRepo, returnsNormally);
+ });
+ test('constructed repos should wor', () async {
+  final store = await HealthDataStore.load(
+      await openDatabase(inMemoryDatabasePath));
+  expect(store, isNotNull);
+  final bpRepo = store!.bpRepo;
+  final r = mockRecord(time: 10000, sys: 123, dia: 45, pul: 67);
+  await bpRepo.add(r);
+  final data = await bpRepo.get(DateRange(
+    start: DateTime.fromMillisecondsSinceEpoch(5000),
+    end: DateTime.fromMillisecondsSinceEpoch(20000),
+  ));
+  expect(data.length, 1);
+  expect(data, contains(r));
+ });
 }