Skip to content

Commit

Permalink
test(shorebird_cli): add missing test for `shorebird collaborators de…
Browse files Browse the repository at this point in the history
…lete` (#511)
  • Loading branch information
felangel authored May 17, 2023
1 parent a5338d5 commit 77710e4
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 77710e4

Please sign in to comment.