fix: gracefully handling patching on a app with no releases (#2247)
Co-authored-by: Bryan Oltman <bryan@shorebird.dev>
This commit is contained in:
@@ -308,6 +308,14 @@ NOTE: this is ${styleBold.wrap('not')} recommended. Asset changes cannot be incl
|
||||
final releases = await codePushClientWrapper.getReleases(
|
||||
appId: appId,
|
||||
);
|
||||
|
||||
if (releases.isEmpty) {
|
||||
logger.warn(
|
||||
'''No releases found for app $appId. You need to make first a release before you can create a patch.''',
|
||||
);
|
||||
throw ProcessExit(ExitCode.usage.code);
|
||||
}
|
||||
|
||||
return logger.chooseOne<Release>(
|
||||
'Which release would you like to patch?',
|
||||
choices: releases.sortedBy((r) => r.createdAt).reversed.toList(),
|
||||
|
||||
@@ -678,6 +678,27 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
group('when prompting for releases, but there is none', () {
|
||||
setUp(() {
|
||||
when(
|
||||
() => codePushClientWrapper.getReleases(appId: any(named: 'appId')),
|
||||
).thenAnswer((_) async => []);
|
||||
});
|
||||
|
||||
test('warns and exits', () async {
|
||||
await expectLater(
|
||||
() => runWithOverrides(command.run),
|
||||
exitsWithCode(ExitCode.usage),
|
||||
);
|
||||
|
||||
verify(
|
||||
() => logger.warn(
|
||||
'''No releases found for app $appId. You need to make first a release before you can create a patch.''',
|
||||
),
|
||||
).called(1);
|
||||
});
|
||||
});
|
||||
|
||||
group('when running on CI', () {
|
||||
setUp(() {
|
||||
when(() => shorebirdEnv.canAcceptUserInput).thenReturn(false);
|
||||
|
||||
Reference in New Issue
Block a user