Skip to content

Commit 185c8c5

Browse files
committed
test [nfc]: Introduce apiExceptionBadEventQueueId
This is another common type of error that is expected to be reused more later Signed-off-by: Zixuan James Li <[email protected]>
1 parent 55fe45f commit 185c8c5

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

test/example_data.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,18 @@ ZulipApiException apiBadRequest({
3939
data: {}, message: message);
4040
}
4141

42+
/// The error for the "events" route when the target event queue has been
43+
/// garbage collected.
44+
///
45+
/// https://zulip.com/api/get-events#bad_event_queue_id-errors
46+
ZulipApiException apiExceptionBadEventQueueId({
47+
String queueId = 'fb67bf8a-c031-47cc-84cf-ed80accacda8',
48+
}) {
49+
return ZulipApiException(
50+
routeName: 'events', httpStatus: 400, code: 'BAD_EVENT_QUEUE_ID',
51+
data: {'queue_id': queueId}, message: 'Bad event queue ID: $queueId');
52+
}
53+
4254
/// The error the server gives when the client's credentials
4355
/// (API key together with email and realm URL) are no longer valid.
4456
///

test/model/store_test.dart

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -757,11 +757,8 @@ void main() {
757757
}
758758

759759
void prepareExpiredEventQueue() {
760-
connection.prepare(httpStatus: 400, json: {
761-
'result': 'error', 'code': 'BAD_EVENT_QUEUE_ID',
762-
'queue_id': updateMachine.queueId,
763-
'msg': 'Bad event queue ID: ${updateMachine.queueId}',
764-
});
760+
connection.prepare(apiException: eg.apiExceptionBadEventQueueId(
761+
queueId: updateMachine.queueId));
765762
}
766763

767764
Future<void> prepareHandleEventError() async {

test/widgets/message_list_test.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import 'package:flutter/rendering.dart';
77
import 'package:flutter_checks/flutter_checks.dart';
88
import 'package:flutter_test/flutter_test.dart';
99
import 'package:http/http.dart' as http;
10-
import 'package:zulip/api/exception.dart';
1110
import 'package:zulip/api/model/events.dart';
1211
import 'package:zulip/api/model/initial_snapshot.dart';
1312
import 'package:zulip/api/model/model.dart';
@@ -143,9 +142,8 @@ void main() {
143142
updateMachine.debugPauseLoop();
144143
updateMachine.poll();
145144

146-
updateMachine.debugPrepareLoopError(ZulipApiException(
147-
routeName: 'events', httpStatus: 400, code: 'BAD_EVENT_QUEUE_ID',
148-
data: {'queue_id': updateMachine.queueId}, message: 'Bad event queue ID.'));
145+
updateMachine.debugPrepareLoopError(
146+
eg.apiExceptionBadEventQueueId(queueId: updateMachine.queueId));
149147
updateMachine.debugAdvanceLoop();
150148
await tester.pump();
151149
// Event queue has been replaced; but the [MessageList] hasn't been

0 commit comments

Comments
 (0)