1// Copyright 2014 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5import 'package:flutter_tools/src/dart/pub.dart';
6
7final class ThrowingPub implements Pub {
8 const ThrowingPub();
9
10 @override
11 Never noSuchMethod(Invocation invocation) {
12 throw UnsupportedError(
13 'Attempted to invoke pub during test, which otherwise was unexpected. '
14 'This error may be caused by either changing the implementation details '
15 'of the Flutter CLI in where the "Pub" class is now being used, or '
16 'adding a unit test that transitively depends on "Pub".\n'
17 '\n'
18 'Possible options for resolution:\n'
19 ' 1. Refactor the code or test to not rely on "Pub".\n'
20 ' 2. Create and use a test-appropriate Fake (grep for "implements Pub") '
21 ' for example code across the test/ repo. It is possible that the '
22 ' file you are editing already has an appropriate Fake.\n',
23 );
24 }
25}
26