Unverified Commit 8b144544 authored by Jenn Magder's avatar Jenn Magder Committed by GitHub

Remove MockFlutterVersion from mocks (#78089)

parent c94648f9
...@@ -12,12 +12,11 @@ import 'package:flutter_tools/src/base/terminal.dart'; ...@@ -12,12 +12,11 @@ import 'package:flutter_tools/src/base/terminal.dart';
import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/downgrade.dart'; import 'package:flutter_tools/src/commands/downgrade.dart';
import 'package:flutter_tools/src/persistent_tool_state.dart'; import 'package:flutter_tools/src/persistent_tool_state.dart';
import 'package:flutter_tools/src/version.dart';
import 'package:mockito/mockito.dart'; import 'package:mockito/mockito.dart';
import '../../src/common.dart'; import '../../src/common.dart';
import '../../src/context.dart'; import '../../src/context.dart';
import '../../src/mocks.dart'; import '../../src/fakes.dart';
void main() { void main() {
FileSystem fileSystem; FileSystem fileSystem;
...@@ -25,7 +24,6 @@ void main() { ...@@ -25,7 +24,6 @@ void main() {
AnsiTerminal terminal; AnsiTerminal terminal;
ProcessManager processManager; ProcessManager processManager;
MockStdio mockStdio; MockStdio mockStdio;
FlutterVersion flutterVersion;
setUpAll(() { setUpAll(() {
Cache.disableLocking(); Cache.disableLocking();
...@@ -36,7 +34,6 @@ void main() { ...@@ -36,7 +34,6 @@ void main() {
}); });
setUp(() { setUp(() {
flutterVersion = MockFlutterVersion();
mockStdio = MockStdio(); mockStdio = MockStdio();
processManager = FakeProcessManager.any(); processManager = FakeProcessManager.any();
terminal = MockTerminal(); terminal = MockTerminal();
...@@ -45,6 +42,7 @@ void main() { ...@@ -45,6 +42,7 @@ void main() {
}); });
testUsingContext('Downgrade exits on unknown channel', () async { testUsingContext('Downgrade exits on unknown channel', () async {
final FakeFlutterVersion fakeFlutterVersion = FakeFlutterVersion(channel: 'unknown');
fileSystem.currentDirectory.childFile('.flutter_tool_state') fileSystem.currentDirectory.childFile('.flutter_tool_state')
.writeAsStringSync('{"last-active-master-version":"invalid"}'); .writeAsStringSync('{"last-active-master-version":"invalid"}');
final DowngradeCommand command = DowngradeCommand( final DowngradeCommand command = DowngradeCommand(
...@@ -52,7 +50,7 @@ void main() { ...@@ -52,7 +50,7 @@ void main() {
processManager: processManager, processManager: processManager,
terminal: terminal, terminal: terminal,
stdio: mockStdio, stdio: mockStdio,
flutterVersion: flutterVersion, flutterVersion: fakeFlutterVersion,
logger: bufferLogger, logger: bufferLogger,
); );
...@@ -61,7 +59,7 @@ void main() { ...@@ -61,7 +59,7 @@ void main() {
}); });
testUsingContext('Downgrade exits on no recorded version', () async { testUsingContext('Downgrade exits on no recorded version', () async {
when(flutterVersion.channel).thenReturn('dev'); final FakeFlutterVersion fakeFlutterVersion = FakeFlutterVersion(channel: 'dev');
fileSystem.currentDirectory.childFile('.flutter_tool_state') fileSystem.currentDirectory.childFile('.flutter_tool_state')
.writeAsStringSync('{"last-active-master-version":"abcd"}'); .writeAsStringSync('{"last-active-master-version":"abcd"}');
final DowngradeCommand command = DowngradeCommand( final DowngradeCommand command = DowngradeCommand(
...@@ -77,7 +75,7 @@ void main() { ...@@ -77,7 +75,7 @@ void main() {
]), ]),
terminal: terminal, terminal: terminal,
stdio: mockStdio, stdio: mockStdio,
flutterVersion: flutterVersion, flutterVersion: fakeFlutterVersion,
logger: bufferLogger, logger: bufferLogger,
); );
...@@ -90,7 +88,7 @@ void main() { ...@@ -90,7 +88,7 @@ void main() {
}); });
testUsingContext('Downgrade exits on unknown recorded version', () async { testUsingContext('Downgrade exits on unknown recorded version', () async {
when(flutterVersion.channel).thenReturn('master'); final FakeFlutterVersion fakeFlutterVersion = FakeFlutterVersion(channel: 'master');
fileSystem.currentDirectory.childFile('.flutter_tool_state') fileSystem.currentDirectory.childFile('.flutter_tool_state')
.writeAsStringSync('{"last-active-master-version":"invalid"}'); .writeAsStringSync('{"last-active-master-version":"invalid"}');
final DowngradeCommand command = DowngradeCommand( final DowngradeCommand command = DowngradeCommand(
...@@ -105,7 +103,7 @@ void main() { ...@@ -105,7 +103,7 @@ void main() {
]), ]),
terminal: terminal, terminal: terminal,
stdio: mockStdio, stdio: mockStdio,
flutterVersion: flutterVersion, flutterVersion: fakeFlutterVersion,
logger: bufferLogger, logger: bufferLogger,
); );
...@@ -114,7 +112,7 @@ void main() { ...@@ -114,7 +112,7 @@ void main() {
}); });
testUsingContext('Downgrade prompts for user input when terminal is attached - y', () async { testUsingContext('Downgrade prompts for user input when terminal is attached - y', () async {
when(flutterVersion.channel).thenReturn('master'); final FakeFlutterVersion fakeFlutterVersion = FakeFlutterVersion(channel: 'master');
when(mockStdio.hasTerminal).thenReturn(true); when(mockStdio.hasTerminal).thenReturn(true);
fileSystem.currentDirectory.childFile('.flutter_tool_state') fileSystem.currentDirectory.childFile('.flutter_tool_state')
.writeAsStringSync('{"last-active-master-version":"g6b00b5e88"}'); .writeAsStringSync('{"last-active-master-version":"g6b00b5e88"}');
...@@ -123,7 +121,7 @@ void main() { ...@@ -123,7 +121,7 @@ void main() {
processManager: processManager, processManager: processManager,
terminal: terminal, terminal: terminal,
stdio: mockStdio, stdio: mockStdio,
flutterVersion: flutterVersion, flutterVersion: fakeFlutterVersion,
logger: bufferLogger, logger: bufferLogger,
); );
...@@ -144,7 +142,7 @@ void main() { ...@@ -144,7 +142,7 @@ void main() {
}); });
testUsingContext('Downgrade prompts for user input when terminal is attached - n', () async { testUsingContext('Downgrade prompts for user input when terminal is attached - n', () async {
when(flutterVersion.channel).thenReturn('master'); final FakeFlutterVersion fakeFlutterVersion = FakeFlutterVersion(channel: 'master');
when(mockStdio.hasTerminal).thenReturn(true); when(mockStdio.hasTerminal).thenReturn(true);
fileSystem.currentDirectory.childFile('.flutter_tool_state') fileSystem.currentDirectory.childFile('.flutter_tool_state')
.writeAsStringSync('{"last-active-master-version":"g6b00b5e88"}'); .writeAsStringSync('{"last-active-master-version":"g6b00b5e88"}');
...@@ -153,7 +151,7 @@ void main() { ...@@ -153,7 +151,7 @@ void main() {
processManager: processManager, processManager: processManager,
terminal: terminal, terminal: terminal,
stdio: mockStdio, stdio: mockStdio,
flutterVersion: flutterVersion, flutterVersion: fakeFlutterVersion,
logger: bufferLogger, logger: bufferLogger,
); );
...@@ -174,7 +172,7 @@ void main() { ...@@ -174,7 +172,7 @@ void main() {
}); });
testUsingContext('Downgrade does not prompt when there is no terminal', () async { testUsingContext('Downgrade does not prompt when there is no terminal', () async {
when(flutterVersion.channel).thenReturn('master'); final FakeFlutterVersion fakeFlutterVersion = FakeFlutterVersion(channel: 'master');
when(mockStdio.hasTerminal).thenReturn(false); when(mockStdio.hasTerminal).thenReturn(false);
fileSystem.currentDirectory.childFile('.flutter_tool_state') fileSystem.currentDirectory.childFile('.flutter_tool_state')
.writeAsStringSync('{"last-active-master-version":"g6b00b5e88"}'); .writeAsStringSync('{"last-active-master-version":"g6b00b5e88"}');
...@@ -186,7 +184,7 @@ void main() { ...@@ -186,7 +184,7 @@ void main() {
processManager: processManager, processManager: processManager,
terminal: terminal, terminal: terminal,
stdio: mockStdio, stdio: mockStdio,
flutterVersion: flutterVersion, flutterVersion: fakeFlutterVersion,
logger: bufferLogger, logger: bufferLogger,
); );
...@@ -201,7 +199,7 @@ void main() { ...@@ -201,7 +199,7 @@ void main() {
}); });
testUsingContext('Downgrade performs correct git commands', () async { testUsingContext('Downgrade performs correct git commands', () async {
when(flutterVersion.channel).thenReturn('master'); final FakeFlutterVersion fakeFlutterVersion = FakeFlutterVersion(channel: 'master');
when(mockStdio.hasTerminal).thenReturn(false); when(mockStdio.hasTerminal).thenReturn(false);
fileSystem.currentDirectory.childFile('.flutter_tool_state') fileSystem.currentDirectory.childFile('.flutter_tool_state')
.writeAsStringSync('{"last-active-master-version":"g6b00b5e88"}'); .writeAsStringSync('{"last-active-master-version":"g6b00b5e88"}');
...@@ -230,7 +228,7 @@ void main() { ...@@ -230,7 +228,7 @@ void main() {
]), ]),
terminal: terminal, terminal: terminal,
stdio: mockStdio, stdio: mockStdio,
flutterVersion: flutterVersion, flutterVersion: fakeFlutterVersion,
logger: bufferLogger, logger: bufferLogger,
); );
......
...@@ -15,7 +15,6 @@ import 'package:flutter_tools/src/build_info.dart'; ...@@ -15,7 +15,6 @@ import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/globals.dart' as globals; import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:flutter_tools/src/ios/devices.dart'; import 'package:flutter_tools/src/ios/devices.dart';
import 'package:flutter_tools/src/project.dart'; import 'package:flutter_tools/src/project.dart';
import 'package:flutter_tools/src/version.dart';
import 'package:mockito/mockito.dart'; import 'package:mockito/mockito.dart';
import 'package:process/process.dart'; import 'package:process/process.dart';
...@@ -235,4 +234,3 @@ class MockStdIn extends Mock implements IOSink { ...@@ -235,4 +234,3 @@ class MockStdIn extends Mock implements IOSink {
} }
class MockStream extends Mock implements Stream<List<int>> {} class MockStream extends Mock implements Stream<List<int>> {}
class MockFlutterVersion extends Mock implements FlutterVersion {}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment