Skip to content

Commit

Permalink
Merge pull request #359 from poppingmoon/fix-miauth-test
Browse files Browse the repository at this point in the history
MiAuthのテストでMisskey.endpointsをモックする
  • Loading branch information
shiosyakeyakini-info authored Oct 1, 2023
2 parents 1cf5bf6 + 10f95f6 commit 1120d6c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
3 changes: 2 additions & 1 deletion lib/repository/account_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down
20 changes: 16 additions & 4 deletions test/repository/account_repository/open_mi_auth_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);

Expand Down

0 comments on commit 1120d6c

Please sign in to comment.