Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(shorebird_cli): remove shorebird account downgrade command #1347

Merged
merged 1 commit into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/shorebird_cli/lib/src/command_runner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ class ShorebirdCliCommandRunner extends CompletionCommandRunner<int> {
'are building Flutter locally.',
);

addCommand(AccountCommand());
addCommand(AppsCommand());
addCommand(BuildCommand());
addCommand(CacheCommand());
Expand Down
2 changes: 0 additions & 2 deletions packages/shorebird_cli/lib/src/commands/account/account.dart

This file was deleted.

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion packages/shorebird_cli/lib/src/commands/commands.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export 'account/account.dart';
export 'apps/apps.dart';
export 'build/build_command.dart';
export 'cache/cache.dart';
Expand Down

This file was deleted.

13 changes: 0 additions & 13 deletions packages/shorebird_code_push_client/lib/src/code_push_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -498,19 +498,6 @@ class CodePushClient {
}
}

/// Cancels the current user's subscription.
Future<DateTime> cancelSubscription() async {
final response = await _httpClient.delete(Uri.parse('$_v1/subscriptions'));

if (response.statusCode != HttpStatus.ok) {
throw _parseErrorResponse(response.statusCode, response.body);
}

final json = jsonDecode(response.body) as Map<String, dynamic>;
final timestamp = json['expiration_date'] as int;
return DateTime.fromMillisecondsSinceEpoch(timestamp * 1000);
}

/// Closes the client.
void close() => _httpClient.close();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2074,64 +2074,6 @@ void main() {
});
});

group('cancelSubscription', () {
late Uri uri;

setUp(() {
uri = Uri.parse('${codePushClient.hostedUri}/api/v1/subscriptions');
});

test('makes the correct request', () async {
codePushClient.cancelSubscription().ignore();
final request = verify(() => httpClient.send(captureAny()))
.captured
.single as http.BaseRequest;
expect(request.method, equals('DELETE'));
expect(request.url, equals(v1('subscriptions')));
expect(request.hasStandardHeaders, isTrue);
});

test('throws an exception if the http request fails', () {
when(() => httpClient.send(any())).thenAnswer(
(_) async => http.StreamedResponse(
const Stream.empty(),
HttpStatus.badRequest,
),
);

expect(
codePushClient.cancelSubscription(),
throwsA(
isA<CodePushException>().having(
(e) => e.message,
'message',
CodePushClient.unknownErrorMessage,
),
),
);
});

test('completes when request succeeds', () async {
const timestamp = 1681455600;
when(() => httpClient.send(any())).thenAnswer(
(_) async => http.StreamedResponse(
Stream.value(
utf8.encode(json.encode({'expiration_date': 1681455600})),
),
HttpStatus.ok,
),
);

final response = await codePushClient.cancelSubscription();

expect(response.millisecondsSinceEpoch, timestamp * 1000);
final request = verify(() => httpClient.send(captureAny()))
.captured
.single as http.BaseRequest;
expect(request.url, equals(uri));
});
});

group('close', () {
test('closes the underlying client', () {
codePushClient.close();
Expand Down
Loading