From d481a771daae0ca8e9235c6b8c5fa79069b4dc9e Mon Sep 17 00:00:00 2001 From: Ming Ming Date: Fri, 5 Aug 2022 17:40:11 +0800 Subject: [PATCH] Fix EventBus not registered in test --- app/test/use_case/sync_favorite_test.dart | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/test/use_case/sync_favorite_test.dart b/app/test/use_case/sync_favorite_test.dart index f79c6822..0df42bca 100644 --- a/app/test/use_case/sync_favorite_test.dart +++ b/app/test/use_case/sync_favorite_test.dart @@ -1,4 +1,6 @@ import 'package:drift/drift.dart' as sql; +import 'package:event_bus/event_bus.dart'; +import 'package:kiwi/kiwi.dart'; import 'package:nc_photos/di_container.dart'; import 'package:nc_photos/entity/favorite.dart'; import 'package:nc_photos/entity/sqlite_table.dart' as sql; @@ -10,6 +12,8 @@ import '../mock_type.dart'; import '../test_util.dart' as util; void main() { + KiwiContainer().registerInstance(MockEventBus()); + group("SyncFavorite", () { test("new", _new); test("remove", _remove); @@ -43,7 +47,7 @@ Future _new() async { await SyncFavorite(c)(account); expect( - await listSqliteDbFavoriteFileIds(c.sqliteDb), + await _listSqliteDbFavoriteFileIds(c.sqliteDb), {101, 102, 103, 104}, ); } @@ -73,12 +77,12 @@ Future _remove() async { await SyncFavorite(c)(account); expect( - await listSqliteDbFavoriteFileIds(c.sqliteDb), + await _listSqliteDbFavoriteFileIds(c.sqliteDb), {103, 104}, ); } -Future> listSqliteDbFavoriteFileIds(sql.SqliteDb db) async { +Future> _listSqliteDbFavoriteFileIds(sql.SqliteDb db) async { final query = db.selectOnly(db.files).join([ sql.innerJoin( db.accountFiles, db.accountFiles.file.equalsExp(db.files.rowId)),