From 77710e4a0b65746d2b7ebbc887a2c8e6b1ff949b Mon Sep 17 00:00:00 2001 From: Felix Angelov Date: Wed, 17 May 2023 16:15:29 -0500 Subject: [PATCH] test(shorebird_cli): add missing test for `shorebird collaborators delete` (#511) --- .../delete_collaborators_command_test.dart | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/packages/shorebird_cli/test/src/commands/collaborators/delete_collaborators_command_test.dart b/packages/shorebird_cli/test/src/commands/collaborators/delete_collaborators_command_test.dart index cd511fd3a..a250d4a31 100644 --- a/packages/shorebird_cli/test/src/commands/collaborators/delete_collaborators_command_test.dart +++ b/packages/shorebird_cli/test/src/commands/collaborators/delete_collaborators_command_test.dart @@ -1,7 +1,10 @@ +import 'dart:io'; + import 'package:args/args.dart'; import 'package:http/http.dart' as http; import 'package:mason_logger/mason_logger.dart'; import 'package:mocktail/mocktail.dart'; +import 'package:path/path.dart' as p; import 'package:shorebird_cli/src/auth/auth.dart'; import 'package:shorebird_cli/src/commands/commands.dart'; import 'package:shorebird_code_push_client/shorebird_code_push_client.dart'; @@ -162,6 +165,32 @@ void main() { ).called(1); }); + test('uses app-id from shorebird.yaml if one exists', () async { + final tempDir = Directory.systemTemp.createTempSync(); + File( + p.join(tempDir.path, 'shorebird.yaml'), + ).writeAsStringSync('app_id: $appId'); + when(() => argResults['app-id']).thenReturn(null); + when( + () => codePushClient.deleteCollaborator( + appId: any(named: 'appId'), + userId: any(named: 'userId'), + ), + ).thenAnswer((_) async {}); + final result = await IOOverrides.runZoned( + () => command.run(), + getCurrentDirectory: () => tempDir, + ); + expect(result, ExitCode.success.code); + verify(() => logger.success('\n✅ Collaborator Deleted!')).called(1); + verify( + () => codePushClient.deleteCollaborator( + appId: appId, + userId: collaborator.userId, + ), + ).called(1); + }); + test('returns ExitCode.success on success', () async { when( () => codePushClient.deleteCollaborator(