blob: d6cf64f5e2fe7ea0d78deea1612743c02c7f5047 [file] [log] [blame]
// Copyright 2019 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'package:cocoon_service/src/model/luci/push_message.dart';
import 'package:cocoon_service/src/request_handling/api_request_handler.dart';
import 'package:cocoon_service/src/request_handling/body.dart';
import 'package:cocoon_service/src/request_handling/request_handler.dart';
import 'package:cocoon_service/src/request_handling/subscription_handler.dart';
import 'package:meta/meta.dart';
import 'fake_authentication.dart';
import 'request_handler_tester.dart';
class SubscriptionTester extends RequestHandlerTester {
SubscriptionTester({
super.request,
FakeAuthenticatedContext? context,
this.message = const PushMessage(),
}) : context = context ?? FakeAuthenticatedContext();
FakeAuthenticatedContext context;
PushMessage message;
@override
@protected
Future<T> run<T extends Body>(Future<T> Function() callback) {
return super.run<T>(() {
return runZoned<Future<T>>(
() {
return callback();
},
zoneValues: <RequestKey<dynamic>, Object>{
ApiKey.authContext: context,
PubSubKey.message: message,
},
);
});
}
}