refactor(code_push_client): upgrade analysis_options (#2719)
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
include: package:very_good_analysis/analysis_options.5.1.0.yaml
|
include: package:very_good_analysis/analysis_options.7.0.0.yaml
|
||||||
analyzer:
|
analyzer:
|
||||||
exclude:
|
exclude:
|
||||||
- lib/src/version.dart
|
- lib/src/version.dart
|
||||||
|
- example/**
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
// ignore_for_file: unused_local_variable
|
|
||||||
|
|
||||||
import 'package:shorebird_code_push_client/shorebird_code_push_client.dart';
|
import 'package:shorebird_code_push_client/shorebird_code_push_client.dart';
|
||||||
|
|
||||||
Future<void> main() async {
|
Future<void> main() async {
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
/// The Shorebird CodePush API Client
|
|
||||||
library shorebird_code_push_client;
|
|
||||||
|
|
||||||
export 'package:shorebird_code_push_protocol/shorebird_code_push_protocol.dart';
|
export 'package:shorebird_code_push_protocol/shorebird_code_push_protocol.dart';
|
||||||
|
|
||||||
export 'src/code_push_client.dart';
|
export 'src/code_push_client.dart';
|
||||||
|
|||||||
@@ -548,7 +548,7 @@ class CodePushClient {
|
|||||||
try {
|
try {
|
||||||
final body = json.decode(response) as Map<String, dynamic>;
|
final body = json.decode(response) as Map<String, dynamic>;
|
||||||
error = ErrorResponse.fromJson(body);
|
error = ErrorResponse.fromJson(body);
|
||||||
} catch (_) {
|
} on Exception {
|
||||||
throw exceptionBuilder(message: unknownErrorMessage);
|
throw exceptionBuilder(message: unknownErrorMessage);
|
||||||
}
|
}
|
||||||
return exceptionBuilder(message: error.message, details: error.details);
|
return exceptionBuilder(message: error.message, details: error.details);
|
||||||
|
|||||||
@@ -21,4 +21,4 @@ dev_dependencies:
|
|||||||
build_version: ^2.0.0
|
build_version: ^2.0.0
|
||||||
mocktail: ^1.0.0
|
mocktail: ^1.0.0
|
||||||
test: ^1.19.2
|
test: ^1.19.2
|
||||||
very_good_analysis: ^6.0.0
|
very_good_analysis: ^7.0.0
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// ignore_for_file: prefer_const_constructors
|
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
@@ -51,7 +50,7 @@ void main() {
|
|||||||
customHeaders: customHeaders,
|
customHeaders: customHeaders,
|
||||||
);
|
);
|
||||||
when(() => httpClient.send(any())).thenAnswer(
|
when(() => httpClient.send(any())).thenAnswer(
|
||||||
(_) async => http.StreamedResponse(Stream.empty(), HttpStatus.ok),
|
(_) async => http.StreamedResponse(const Stream.empty(), HttpStatus.ok),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -75,7 +74,7 @@ void main() {
|
|||||||
test('throws CodePushUpgradeRequiredException on 426 response', () async {
|
test('throws CodePushUpgradeRequiredException on 426 response', () async {
|
||||||
when(() => httpClient.send(any())).thenAnswer(
|
when(() => httpClient.send(any())).thenAnswer(
|
||||||
(_) async => http.StreamedResponse(
|
(_) async => http.StreamedResponse(
|
||||||
Stream.empty(),
|
const Stream.empty(),
|
||||||
HttpStatus.upgradeRequired,
|
HttpStatus.upgradeRequired,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -89,7 +88,7 @@ void main() {
|
|||||||
test('throws CodePushForbiddenException on 403 response', () async {
|
test('throws CodePushForbiddenException on 403 response', () async {
|
||||||
when(() => httpClient.send(any())).thenAnswer(
|
when(() => httpClient.send(any())).thenAnswer(
|
||||||
(_) async => http.StreamedResponse(
|
(_) async => http.StreamedResponse(
|
||||||
Stream.empty(),
|
const Stream.empty(),
|
||||||
HttpStatus.forbidden,
|
HttpStatus.forbidden,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -184,7 +183,9 @@ void main() {
|
|||||||
platform: platform,
|
platform: platform,
|
||||||
hash: hash,
|
hash: hash,
|
||||||
);
|
);
|
||||||
} catch (_) {}
|
} on Exception {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
|
||||||
final request = verify(() => httpClient.send(captureAny()))
|
final request = verify(() => httpClient.send(captureAny()))
|
||||||
.captured
|
.captured
|
||||||
@@ -223,7 +224,9 @@ void main() {
|
|||||||
hash: hash,
|
hash: hash,
|
||||||
hashSignature: hashSignature,
|
hashSignature: hashSignature,
|
||||||
);
|
);
|
||||||
} catch (_) {}
|
} on Exception {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
|
||||||
final request = verify(() => httpClient.send(captureAny()))
|
final request = verify(() => httpClient.send(captureAny()))
|
||||||
.captured
|
.captured
|
||||||
@@ -317,7 +320,7 @@ void main() {
|
|||||||
Stream.value(
|
Stream.value(
|
||||||
utf8.encode(
|
utf8.encode(
|
||||||
json.encode(
|
json.encode(
|
||||||
CreatePatchArtifactResponse(
|
const CreatePatchArtifactResponse(
|
||||||
id: artifactId,
|
id: artifactId,
|
||||||
patchId: patchId,
|
patchId: patchId,
|
||||||
arch: arch,
|
arch: arch,
|
||||||
@@ -331,7 +334,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
HttpStatus.ok,
|
HttpStatus.ok,
|
||||||
),
|
),
|
||||||
http.StreamedResponse(Stream.empty(), HttpStatus.badRequest),
|
http.StreamedResponse(const Stream.empty(), HttpStatus.badRequest),
|
||||||
];
|
];
|
||||||
when(() => httpClient.send(any())).thenAnswer(
|
when(() => httpClient.send(any())).thenAnswer(
|
||||||
(_) async => responses.removeAt(0),
|
(_) async => responses.removeAt(0),
|
||||||
@@ -376,7 +379,7 @@ void main() {
|
|||||||
Stream.value(
|
Stream.value(
|
||||||
utf8.encode(
|
utf8.encode(
|
||||||
json.encode(
|
json.encode(
|
||||||
CreatePatchArtifactResponse(
|
const CreatePatchArtifactResponse(
|
||||||
id: artifactId,
|
id: artifactId,
|
||||||
patchId: patchId,
|
patchId: patchId,
|
||||||
arch: arch,
|
arch: arch,
|
||||||
@@ -390,7 +393,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
HttpStatus.ok,
|
HttpStatus.ok,
|
||||||
),
|
),
|
||||||
http.StreamedResponse(Stream.empty(), HttpStatus.noContent),
|
http.StreamedResponse(const Stream.empty(), HttpStatus.noContent),
|
||||||
];
|
];
|
||||||
when(() => httpClient.send(any())).thenAnswer(
|
when(() => httpClient.send(any())).thenAnswer(
|
||||||
(_) async => responses.removeAt(0),
|
(_) async => responses.removeAt(0),
|
||||||
@@ -440,7 +443,7 @@ void main() {
|
|||||||
final fixture = File(path.join(tempDir.path, 'release.txt'))
|
final fixture = File(path.join(tempDir.path, 'release.txt'))
|
||||||
..createSync()
|
..createSync()
|
||||||
..writeAsStringSync('hello');
|
..writeAsStringSync('hello');
|
||||||
final expectedRequest = CreateReleaseArtifactRequest(
|
const expectedRequest = CreateReleaseArtifactRequest(
|
||||||
arch: arch,
|
arch: arch,
|
||||||
platform: platform,
|
platform: platform,
|
||||||
hash: hash,
|
hash: hash,
|
||||||
@@ -461,7 +464,9 @@ void main() {
|
|||||||
canSideload: canSideload,
|
canSideload: canSideload,
|
||||||
podfileLockHash: null,
|
podfileLockHash: null,
|
||||||
);
|
);
|
||||||
} catch (_) {}
|
} on Exception {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
|
||||||
final request = verify(() => httpClient.send(captureAny()))
|
final request = verify(() => httpClient.send(captureAny()))
|
||||||
.captured
|
.captured
|
||||||
@@ -473,7 +478,7 @@ void main() {
|
|||||||
);
|
);
|
||||||
expect(request.hasHeaders(expectedHeaders), isTrue);
|
expect(request.hasHeaders(expectedHeaders), isTrue);
|
||||||
expect(
|
expect(
|
||||||
MapEquality<String, dynamic>().equals(
|
const MapEquality<String, dynamic>().equals(
|
||||||
request.fields,
|
request.fields,
|
||||||
expectedRequest.toJson(),
|
expectedRequest.toJson(),
|
||||||
),
|
),
|
||||||
@@ -488,7 +493,7 @@ void main() {
|
|||||||
final fixture = File(path.join(tempDir.path, 'release.txt'))
|
final fixture = File(path.join(tempDir.path, 'release.txt'))
|
||||||
..createSync()
|
..createSync()
|
||||||
..writeAsStringSync('hello');
|
..writeAsStringSync('hello');
|
||||||
final expectedRequest = CreateReleaseArtifactRequest(
|
const expectedRequest = CreateReleaseArtifactRequest(
|
||||||
arch: arch,
|
arch: arch,
|
||||||
platform: platform,
|
platform: platform,
|
||||||
hash: hash,
|
hash: hash,
|
||||||
@@ -509,7 +514,9 @@ void main() {
|
|||||||
canSideload: canSideload,
|
canSideload: canSideload,
|
||||||
podfileLockHash: podfileLockHash,
|
podfileLockHash: podfileLockHash,
|
||||||
);
|
);
|
||||||
} catch (_) {}
|
} on Exception {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
|
||||||
final request = verify(() => httpClient.send(captureAny()))
|
final request = verify(() => httpClient.send(captureAny()))
|
||||||
.captured
|
.captured
|
||||||
@@ -521,7 +528,7 @@ void main() {
|
|||||||
);
|
);
|
||||||
expect(request.hasHeaders(expectedHeaders), isTrue);
|
expect(request.hasHeaders(expectedHeaders), isTrue);
|
||||||
expect(
|
expect(
|
||||||
MapEquality<String, dynamic>().equals(
|
const MapEquality<String, dynamic>().equals(
|
||||||
request.fields,
|
request.fields,
|
||||||
expectedRequest.toJson(),
|
expectedRequest.toJson(),
|
||||||
),
|
),
|
||||||
@@ -533,7 +540,7 @@ void main() {
|
|||||||
test('throws an exception if the http request fails (unknown)', () async {
|
test('throws an exception if the http request fails (unknown)', () async {
|
||||||
when(() => httpClient.send(any())).thenAnswer((_) async {
|
when(() => httpClient.send(any())).thenAnswer((_) async {
|
||||||
return http.StreamedResponse(
|
return http.StreamedResponse(
|
||||||
Stream.empty(),
|
const Stream.empty(),
|
||||||
HttpStatus.failedDependency,
|
HttpStatus.failedDependency,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -662,7 +669,7 @@ void main() {
|
|||||||
Stream.value(
|
Stream.value(
|
||||||
utf8.encode(
|
utf8.encode(
|
||||||
json.encode(
|
json.encode(
|
||||||
CreateReleaseArtifactResponse(
|
const CreateReleaseArtifactResponse(
|
||||||
id: artifactId,
|
id: artifactId,
|
||||||
releaseId: releaseId,
|
releaseId: releaseId,
|
||||||
arch: arch,
|
arch: arch,
|
||||||
@@ -676,7 +683,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
HttpStatus.ok,
|
HttpStatus.ok,
|
||||||
),
|
),
|
||||||
http.StreamedResponse(Stream.empty(), HttpStatus.badRequest),
|
http.StreamedResponse(const Stream.empty(), HttpStatus.badRequest),
|
||||||
];
|
];
|
||||||
when(() => httpClient.send(any())).thenAnswer(
|
when(() => httpClient.send(any())).thenAnswer(
|
||||||
(_) async => responses.removeAt(0),
|
(_) async => responses.removeAt(0),
|
||||||
@@ -723,7 +730,7 @@ void main() {
|
|||||||
Stream.value(
|
Stream.value(
|
||||||
utf8.encode(
|
utf8.encode(
|
||||||
json.encode(
|
json.encode(
|
||||||
CreateReleaseArtifactResponse(
|
const CreateReleaseArtifactResponse(
|
||||||
id: artifactId,
|
id: artifactId,
|
||||||
releaseId: releaseId,
|
releaseId: releaseId,
|
||||||
arch: arch,
|
arch: arch,
|
||||||
@@ -737,7 +744,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
HttpStatus.ok,
|
HttpStatus.ok,
|
||||||
),
|
),
|
||||||
http.StreamedResponse(Stream.empty(), HttpStatus.noContent),
|
http.StreamedResponse(const Stream.empty(), HttpStatus.noContent),
|
||||||
];
|
];
|
||||||
when(() => httpClient.send(any())).thenAnswer(
|
when(() => httpClient.send(any())).thenAnswer(
|
||||||
(_) async => responses.removeAt(0),
|
(_) async => responses.removeAt(0),
|
||||||
@@ -841,7 +848,7 @@ void main() {
|
|||||||
(_) async => http.StreamedResponse(
|
(_) async => http.StreamedResponse(
|
||||||
Stream.value(
|
Stream.value(
|
||||||
utf8.encode(
|
utf8.encode(
|
||||||
json.encode(App(id: appId, displayName: displayName)),
|
json.encode(const App(id: appId, displayName: displayName)),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
HttpStatus.ok,
|
HttpStatus.ok,
|
||||||
@@ -933,7 +940,7 @@ void main() {
|
|||||||
Stream.value(
|
Stream.value(
|
||||||
utf8.encode(
|
utf8.encode(
|
||||||
json.encode(
|
json.encode(
|
||||||
Channel(id: channelId, appId: appId, name: channel),
|
const Channel(id: channelId, appId: appId, name: channel),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -1038,7 +1045,7 @@ void main() {
|
|||||||
(_) async => http.StreamedResponse(
|
(_) async => http.StreamedResponse(
|
||||||
Stream.value(
|
Stream.value(
|
||||||
utf8.encode(
|
utf8.encode(
|
||||||
json.encode(Patch(id: patchId, number: patchNumber)),
|
json.encode(const Patch(id: patchId, number: patchNumber)),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
HttpStatus.ok,
|
HttpStatus.ok,
|
||||||
@@ -1286,7 +1293,7 @@ void main() {
|
|||||||
|
|
||||||
group('createUser', () {
|
group('createUser', () {
|
||||||
const userName = 'Jane Doe';
|
const userName = 'Jane Doe';
|
||||||
final user = PrivateUser(
|
const user = PrivateUser(
|
||||||
id: 1,
|
id: 1,
|
||||||
email: 'tester@shorebird.dev',
|
email: 'tester@shorebird.dev',
|
||||||
displayName: userName,
|
displayName: userName,
|
||||||
@@ -1575,8 +1582,8 @@ void main() {
|
|||||||
|
|
||||||
test('completes when request succeeds (populated)', () async {
|
test('completes when request succeeds (populated)', () async {
|
||||||
final expected = [
|
final expected = [
|
||||||
Channel(id: 0, appId: '1', name: 'stable'),
|
const Channel(id: 0, appId: '1', name: 'stable'),
|
||||||
Channel(id: 1, appId: '2', name: 'development'),
|
const Channel(id: 1, appId: '2', name: 'development'),
|
||||||
];
|
];
|
||||||
|
|
||||||
when(() => httpClient.send(any())).thenAnswer(
|
when(() => httpClient.send(any())).thenAnswer(
|
||||||
@@ -1665,7 +1672,7 @@ void main() {
|
|||||||
when(() => httpClient.send(any())).thenAnswer(
|
when(() => httpClient.send(any())).thenAnswer(
|
||||||
(_) async => http.StreamedResponse(
|
(_) async => http.StreamedResponse(
|
||||||
Stream.value(
|
Stream.value(
|
||||||
utf8.encode(json.encode(GetReleasesResponse(releases: []))),
|
utf8.encode(json.encode(const GetReleasesResponse(releases: []))),
|
||||||
),
|
),
|
||||||
HttpStatus.ok,
|
HttpStatus.ok,
|
||||||
),
|
),
|
||||||
@@ -1745,12 +1752,12 @@ void main() {
|
|||||||
late ReleasePatch patch;
|
late ReleasePatch patch;
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
patch = ReleasePatch(
|
patch = const ReleasePatch(
|
||||||
id: 0,
|
id: 0,
|
||||||
number: 1,
|
number: 1,
|
||||||
channel: 'stable',
|
channel: 'stable',
|
||||||
isRolledBack: false,
|
isRolledBack: false,
|
||||||
artifacts: const [],
|
artifacts: [],
|
||||||
);
|
);
|
||||||
response = GetReleasePatchesResponse(patches: [patch]);
|
response = GetReleasePatchesResponse(patches: [patch]);
|
||||||
when(() => httpClient.send(any())).thenAnswer(
|
when(() => httpClient.send(any())).thenAnswer(
|
||||||
@@ -1851,7 +1858,7 @@ void main() {
|
|||||||
|
|
||||||
test('completes when request succeeds', () async {
|
test('completes when request succeeds', () async {
|
||||||
final expected = [
|
final expected = [
|
||||||
ReleaseArtifact(
|
const ReleaseArtifact(
|
||||||
id: 0,
|
id: 0,
|
||||||
releaseId: releaseId,
|
releaseId: releaseId,
|
||||||
arch: arch,
|
arch: arch,
|
||||||
|
|||||||
Reference in New Issue
Block a user