From 10f95f637eb85b94029bb938f633050909c42b16 Mon Sep 17 00:00:00 2001 From: poppingmoon <63451158+poppingmoon@users.noreply.github.com> Date: Sun, 1 Oct 2023 13:26:17 +0900 Subject: [PATCH] =?UTF-8?q?MiAuth=E3=81=AE=E3=83=86=E3=82=B9=E3=83=88?= =?UTF-8?q?=E3=81=A7Misskey.endpoints=E3=82=92=E3=83=A2=E3=83=83=E3=82=AF?= =?UTF-8?q?=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/repository/account_repository.dart | 3 ++- .../account_repository/open_mi_auth_test.dart | 20 +++++++++++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/lib/repository/account_repository.dart b/lib/repository/account_repository.dart index 6f045ef69..a71a3bf73 100644 --- a/lib/repository/account_repository.dart +++ b/lib/repository/account_repository.dart @@ -150,7 +150,8 @@ class AccountRepository extends ChangeNotifier { final version = nodeInfoResult["software"]["version"]; - final endpoints = await Misskey(host: server, token: null).endpoints(); + final endpoints = + await reader(misskeyProvider(Account.demoAccount(server))).endpoints(); if (!endpoints.contains("emojis")) { throw SpecifiedException("Miriaと互換性のないソフトウェアです。\n$software $version"); } diff --git a/test/repository/account_repository/open_mi_auth_test.dart b/test/repository/account_repository/open_mi_auth_test.dart index b43928607..cfde4f794 100644 --- a/test/repository/account_repository/open_mi_auth_test.dart +++ b/test/repository/account_repository/open_mi_auth_test.dart @@ -43,8 +43,14 @@ void main() { requestOptions: RequestOptions(), data: AuthTestData.calckeyNodeInfo)); when(dio.get(any)).thenAnswer((realInvocation) async => Response( requestOptions: RequestOptions(), data: AuthTestData.calckeyNodeInfo2)); - final provider = - ProviderContainer(overrides: [dioProvider.overrideWithValue(dio)]); + final mockMisskey = MockMisskey(); + when(mockMisskey.endpoints()).thenAnswer((_) async => []); + final provider = ProviderContainer( + overrides: [ + dioProvider.overrideWithValue(dio), + misskeyProvider.overrideWith((ref, arg) => mockMisskey), + ], + ); final accountRepository = AccountRepository(MockTabSettingsRepository(), MockAccountSettingsRepository(), provider.read); @@ -69,8 +75,14 @@ void main() { when(dio.get(any)).thenAnswer((realInvocation) async => Response( requestOptions: RequestOptions(), data: AuthTestData.oldVerMisskeyNodeInfo2)); - final provider = - ProviderContainer(overrides: [dioProvider.overrideWithValue(dio)]); + final mockMisskey = MockMisskey(); + when(mockMisskey.endpoints()).thenAnswer((_) async => []); + final provider = ProviderContainer( + overrides: [ + dioProvider.overrideWithValue(dio), + misskeyProvider.overrideWith((ref, arg) => mockMisskey), + ], + ); final accountRepository = AccountRepository(MockTabSettingsRepository(), MockAccountSettingsRepository(), provider.read);