fix(shorebird_cli): shorebird channels create prompt for channel name (#495)

This commit is contained in:
Felix Angelov
2023-05-15 14:21:38 -05:00
committed by GitHub
parent 632d567dc3
commit 02a74e2a37
2 changed files with 27 additions and 1 deletions
@@ -60,7 +60,10 @@ You must either specify an app id via the "--$_appIdOption" flag or run this com
return ExitCode.usage.code;
}
final channel = results[_channelNameOption] as String;
final channel = results[_channelNameOption] as String? ??
logger.prompt(
'''${lightGreen.wrap('?')} What is the name of the channel you would like to create?''',
);
logger.info(
'''
@@ -100,6 +100,29 @@ void main() {
verify(() => logger.err(error)).called(1);
});
test('prompts for channel name when not provided', () async {
when(() => argResults['name']).thenReturn(null);
when(() => logger.prompt(any())).thenReturn(channelName);
when(
() => codePushClient.createChannel(
appId: any(named: 'appId'),
channel: any(named: 'channel'),
),
).thenAnswer((_) async => channel);
expect(await command.run(), ExitCode.success.code);
verify(
() => logger.prompt(
'''${lightGreen.wrap('?')} What is the name of the channel you would like to create?''',
),
).called(1);
verify(
() => codePushClient.createChannel(
appId: appId,
channel: channel.name,
),
).called(1);
});
test('returns ExitCode.success on success', () async {
when(
() => codePushClient.createChannel(