Skip to content

Commit 92e9478

Browse files
committed
dev deps: Upgrade checks to 0.3.0, handling breaking changes
Changelog: https://github.com/dart-lang/test/blob/master/pkgs/checks/CHANGELOG.md
1 parent d413ffd commit 92e9478

13 files changed

+43
-45
lines changed

pubspec.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,10 @@ packages:
157157
dependency: "direct dev"
158158
description:
159159
name: checks
160-
sha256: "03c1a2e4a4d3341ce0512f1401204ecdcdca8cc035e373820a73929cc0bf4fd3"
160+
sha256: aad431b45a8ae2fa26db8c22e385b9cdec73f72986a1d9d9f2017f4c39ecf5c9
161161
url: "https://pub.dev"
162162
source: hosted
163-
version: "0.2.2"
163+
version: "0.3.0"
164164
cli_util:
165165
dependency: transitive
166166
description:

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ dev_dependencies:
8686
json_serializable: ^6.5.4
8787
build_runner: ^2.3.3
8888
test: ^1.23.1
89-
checks: ^0.2.2
89+
checks: ^0.3.0
9090
drift_dev: ^2.5.2
9191
fake_async: ^1.3.1
9292

test/api/core_test.dart

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import 'dart:convert';
22
import 'dart:io';
33

44
import 'package:checks/checks.dart';
5-
import 'package:checks/context.dart';
65
import 'package:flutter_gen/gen_l10n/zulip_localizations.dart';
76
import 'package:http/http.dart' as http;
87
import 'package:test/scaffolding.dart';
@@ -85,12 +84,12 @@ void main() {
8584
..url.asString.equals('${eg.realmUrl.origin}/api/v1/example/route')
8685
..headers.deepEquals(authHeader(email: eg.selfAccount.email, apiKey: eg.selfAccount.apiKey))
8786
..fields.deepEquals({})
88-
..files.single.which(it()
87+
..files.single.which((it) => it
8988
..field.equals('file')
9089
..length.equals(length)
9190
..filename.equals(filename)
9291
..has<Future<List<int>>>((f) => f.finalize().toBytes(), 'contents')
93-
.completes(it()..deepEquals(content.expand((l) => l)))
92+
.completes((it) => it..deepEquals(content.expand((l) => l)))
9493
);
9594
});
9695
}
@@ -148,16 +147,16 @@ void main() {
148147
Future<void> checkRequest<T extends Object>(
149148
T exception, Condition<NetworkException> condition) {
150149
return check(tryRequest(exception: exception))
151-
.throws<NetworkException>(it()
150+
.throws<NetworkException>((it) => it
152151
..routeName.equals(kExampleRouteName)
153152
..cause.equals(exception)
154153
..which(condition));
155154
}
156155

157156
final zulipLocalizations = lookupZulipLocalizations(ZulipLocalizations.supportedLocales.first);
158-
checkRequest(http.ClientException('Oops'), it()..message.equals('Oops'));
159-
checkRequest(const TlsException('Oops'), it()..message.equals('Oops'));
160-
checkRequest((foo: 'bar'), it()
157+
checkRequest(http.ClientException('Oops'), (it) => it..message.equals('Oops'));
158+
checkRequest(const TlsException('Oops'), (it) => it..message.equals('Oops'));
159+
checkRequest((foo: 'bar'), (it) => it
161160
..message.equals(zulipLocalizations.errorNetworkRequestFailed));
162161
});
163162

@@ -176,7 +175,7 @@ void main() {
176175
...data,
177176
};
178177
await check(tryRequest(httpStatus: httpStatus, json: json))
179-
.throws<ZulipApiException>(it()
178+
.throws<ZulipApiException>((it) => it
180179
..routeName.equals(kExampleRouteName)
181180
..httpStatus.equals(httpStatus)
182181
..code.equals(expectedCode ?? code!)
@@ -197,7 +196,7 @@ void main() {
197196
int httpStatus = 400, Map<String, dynamic>? json, String? body}) async {
198197
assert((json == null) != (body == null));
199198
await check(tryRequest(httpStatus: httpStatus, json: json, body: body))
200-
.throws<MalformedServerResponseException>(it()
199+
.throws<MalformedServerResponseException>((it) => it
201200
..routeName.equals(kExampleRouteName)
202201
..httpStatus.equals(httpStatus)
203202
..data.deepEquals(json));
@@ -224,7 +223,7 @@ void main() {
224223
Future<void> check5xx({
225224
required int httpStatus, Map<String, dynamic>? json, String? body}) {
226225
return check(tryRequest(httpStatus: httpStatus, json: json, body: body))
227-
.throws<Server5xxException>(it()
226+
.throws<Server5xxException>((it) => it
228227
..routeName.equals(kExampleRouteName)
229228
..httpStatus.equals(httpStatus)
230229
..data.deepEquals(json));
@@ -241,7 +240,7 @@ void main() {
241240
Future<void> checkMalformed({
242241
required int httpStatus, Map<String, dynamic>? json, String? body}) {
243242
return check(tryRequest(httpStatus: httpStatus, json: json, body: body))
244-
.throws<MalformedServerResponseException>(it()
243+
.throws<MalformedServerResponseException>((it) => it
245244
..routeName.equals(kExampleRouteName)
246245
..httpStatus.equals(httpStatus)
247246
..data.deepEquals(json));
@@ -260,13 +259,13 @@ void main() {
260259
Object? Function(Map<String, dynamic>)? fromJson,
261260
}) {
262261
return check(tryRequest(json: json, body: body, fromJson: fromJson))
263-
.throws<MalformedServerResponseException>(it()
262+
.throws<MalformedServerResponseException>((it) => it
264263
..routeName.equals(kExampleRouteName)
265264
..httpStatus.equals(200)
266265
..data.deepEquals(json));
267266
}
268267

269-
await check(tryRequest<Map>(json: {})).completes(it()..deepEquals({}));
268+
await check(tryRequest<Map>(json: {})).completes((it) => it..deepEquals({}));
270269

271270
await checkMalformed(body: jsonEncode([]));
272271
await checkMalformed(body: jsonEncode(null));
@@ -275,7 +274,7 @@ void main() {
275274
await checkMalformed(body: 'not JSON');
276275

277276
await check(tryRequest(json: {'x': 'y'}, fromJson: (json) => json['x'] as String))
278-
.completes(it()..equals('y'));
277+
.completes((it) => it..equals('y'));
279278
await checkMalformed( json: {}, fromJson: (json) => json['x'] as String);
280279
await checkMalformed( json: {'x': 3}, fromJson: (json) => json['x'] as String);
281280
});

test/api/model/model_checks.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ extension ReactionWithVotesChecks on Subject<ReactionWithVotes> {
5050
// No double-votes from one person (we don't expect this from servers)
5151
assert(userIds.length == reactions.length);
5252

53-
return which(it()
53+
return which((it) => it
5454
..reactionType.equals(first.reactionType)
5555
..emojiCode.equals(first.emojiCode)
5656
..userIds.deepEquals(userIds)

test/api/model/model_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ void main() {
5656
check(mkUser({'profile_data': <String, dynamic>{}}).profileData).isNull();
5757
check(mkUser({'profile_data': null}).profileData).isNull();
5858
check(mkUser({'profile_data': {'1': {'value': 'foo'}}}).profileData)
59-
.isNotNull().deepEquals({1: it()});
59+
.isNotNull().deepEquals({1: (it) => it});
6060
});
6161

6262
test('is_system_bot', () {

test/api/model/reaction_test.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import 'package:checks/checks.dart';
2-
import 'package:checks/context.dart';
32
import 'package:test/scaffolding.dart';
43
import 'package:zulip/api/model/reaction.dart';
54

@@ -8,8 +7,8 @@ import 'model_checks.dart';
87
void main() {
98
group('Reactions', () {
109
// helper to cut out "it()..isA<ReactionWithVotes>()" goo for callers
11-
ConditionSubject matchesReactions(List<Reaction> reactions) {
12-
return it()..isA<ReactionWithVotes>().matchesReactions(reactions);
10+
matchesReactions(List<Reaction> reactions) {
11+
return (Subject<Object?> it) => it..isA<ReactionWithVotes>().matchesReactions(reactions);
1312
}
1413

1514
test('fromJson', () {

test/api/notifications_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ void main() {
7676
..senderAvatarUrl.equals(Uri.parse(streamJson['sender_avatar_url']!))
7777
..senderFullName.equals(streamJson['sender_full_name']!)
7878
..zulipMessageId.equals(12345)
79-
..recipient.isA<FcmMessageStreamRecipient>().which(it()
79+
..recipient.isA<FcmMessageStreamRecipient>().which((it) => it
8080
..streamId.equals(42)
8181
..streamName.equals(streamJson['stream']!)
8282
..topic.equals(streamJson['topic']!))
@@ -94,7 +94,7 @@ void main() {
9494

9595
test('optional fields missing cause no error', () {
9696
check(parse({ ...streamJson }..remove('stream')))
97-
.recipient.isA<FcmMessageStreamRecipient>().which(it()
97+
.recipient.isA<FcmMessageStreamRecipient>().which((it) => it
9898
..streamId.equals(42)
9999
..streamName.isNull());
100100
});

test/model/database_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ void main() {
3737
.first;
3838
check(account.toCompanion(false).toJson()).deepEquals({
3939
...accountData.toJson(),
40-
'id': it(),
40+
'id': (it) => it,
4141
'acked_push_token': null,
4242
});
4343
});

test/model/message_list_test.dart

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -281,10 +281,10 @@ void main() async {
281281

282282
final message = model.messages.single;
283283
check(message)
284-
..content.not(it()..equals(updateEvent.renderedContent!))
284+
..content.not((it) => it..equals(updateEvent.renderedContent!))
285285
..lastEditTimestamp.isNull()
286-
..flags.not(it()..deepEquals(updateEvent.flags))
287-
..isMeMessage.not(it()..equals(updateEvent.isMeMessage!));
286+
..flags.not((it) => it..deepEquals(updateEvent.flags))
287+
..isMeMessage.not((it) => it..equals(updateEvent.isMeMessage!));
288288

289289
model.maybeUpdateMessage(updateEvent);
290290
checkNotifiedOnce();
@@ -310,7 +310,7 @@ void main() async {
310310
checkNotNotified();
311311
check(model).messages.single
312312
..content.equals(originalMessage.content)
313-
..content.not(it()..equals(updateEvent.renderedContent!));
313+
..content.not((it) => it..equals(updateEvent.renderedContent!));
314314
});
315315

316316
// TODO(server-5): Cut legacy case for rendering-only message update
@@ -336,7 +336,7 @@ void main() async {
336336
..content.equals(updateEvent.renderedContent!)
337337
// ... edit timestamp is not.
338338
..lastEditTimestamp.equals(originalMessage.lastEditTimestamp)
339-
..lastEditTimestamp.not(it()..equals(updateEvent.editTimestamp));
339+
..lastEditTimestamp.not((it) => it..equals(updateEvent.editTimestamp));
340340
}
341341

342342
test('rendering-only update does not change timestamp', () async {
@@ -545,7 +545,7 @@ void main() async {
545545
model.contents[0] = const ZulipContent(nodes: [
546546
ParagraphNode(links: null, nodes: [TextNode('something outdated')])
547547
]);
548-
check(model.contents[0]).not(it()..equalsNode(correctContent));
548+
check(model.contents[0]).not((it) => it..equalsNode(correctContent));
549549

550550
model.reassemble();
551551
checkNotifiedOnce();
@@ -802,16 +802,16 @@ void main() async {
802802

803803
// We check showSender has the right values in [checkInvariants],
804804
// but to make this test explicit:
805-
check(model.items).deepEquals([
806-
it()..isA<MessageListHistoryStartItem>(),
807-
it()..isA<MessageListRecipientHeaderItem>(),
808-
it()..isA<MessageListMessageItem>().showSender.isTrue(),
809-
it()..isA<MessageListMessageItem>().showSender.isFalse(),
810-
it()..isA<MessageListMessageItem>().showSender.isTrue(),
811-
it()..isA<MessageListRecipientHeaderItem>(),
812-
it()..isA<MessageListMessageItem>().showSender.isTrue(),
813-
it()..isA<MessageListDateSeparatorItem>(),
814-
it()..isA<MessageListMessageItem>().showSender.isTrue(),
805+
check(model.items).deepEquals(<void Function(Subject<Object?>)>[
806+
(it) => it..isA<MessageListHistoryStartItem>(),
807+
(it) => it..isA<MessageListRecipientHeaderItem>(),
808+
(it) => it..isA<MessageListMessageItem>().showSender.isTrue(),
809+
(it) => it..isA<MessageListMessageItem>().showSender.isFalse(),
810+
(it) => it..isA<MessageListMessageItem>().showSender.isTrue(),
811+
(it) => it..isA<MessageListRecipientHeaderItem>(),
812+
(it) => it..isA<MessageListMessageItem>().showSender.isTrue(),
813+
(it) => it..isA<MessageListDateSeparatorItem>(),
814+
(it) => it..isA<MessageListMessageItem>().showSender.isTrue(),
815815
]);
816816
});
817817

test/model/store_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ void main() {
232232
await Future.delayed(Duration.zero);
233233

234234
// The global store has a new store.
235-
check(globalStore.perAccountSync(store.account.id)).not(it()..identicalTo(store));
235+
check(globalStore.perAccountSync(store.account.id)).not((it) => it..identicalTo(store));
236236
updateFromGlobalStore();
237237

238238
// The new UpdateMachine updates the new store.

test/notifications_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ void main() {
123123
..title.equals(expectedTitle)
124124
..body.equals(data.content)
125125
..payload.equals(jsonEncode(data.toJson()))
126-
..notificationDetails.isNotNull().android.isNotNull().which(it()
126+
..notificationDetails.isNotNull().android.isNotNull().which((it) => it
127127
..channelId.equals(NotificationChannelManager.kChannelId)
128128
..tag.equals(expectedTag)
129129
..color.equals(kZulipBrandColor)

test/widgets/action_sheet_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ void main() {
352352
builder.selection = TextSelection.collapsed(offset: builder.text.length);
353353
}
354354
check(contentController).value.equals(builder.value);
355-
check(contentController).not(it()..validationErrors.contains(ContentValidationError.quoteAndReplyInProgress));
355+
check(contentController).not((it) => it..validationErrors.contains(ContentValidationError.quoteAndReplyInProgress));
356356
}
357357

358358
testWidgets('in stream narrow', (WidgetTester tester) async {

test/widgets/store_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ void main() {
142142

143143
// (... even one that really is separate, with its own fresh state node ...)
144144
check(tester.state(find.byType(PerAccountStoreWidget)))
145-
.not(it()..identicalTo(oldState));
145+
.not((it) => it..identicalTo(oldState));
146146

147147
// ... then its child appears immediately, without waiting to load.
148148
check(tester.any(find.textContaining('found store'))).isTrue();

0 commit comments

Comments
 (0)