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';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/downgrade.dart';
import 'package:flutter_tools/src/persistent_tool_state.dart';
import 'package:flutter_tools/src/version.dart';
import 'package:mockito/mockito.dart';
import '../../src/common.dart';
import '../../src/context.dart';
import '../../src/mocks.dart';
import '../../src/fakes.dart';
void main() {
FileSystem fileSystem;
......@@ -25,7 +24,6 @@ void main() {
AnsiTerminal terminal;
ProcessManager processManager;
MockStdio mockStdio;
FlutterVersion flutterVersion;
setUpAll(() {
Cache.disableLocking();
......@@ -36,7 +34,6 @@ void main() {
});
setUp(() {
flutterVersion = MockFlutterVersion();
mockStdio = MockStdio();
processManager = FakeProcessManager.any();
terminal = MockTerminal();
......@@ -45,6 +42,7 @@ void main() {
});
testUsingContext('Downgrade exits on unknown channel', () async {
final FakeFlutterVersion fakeFlutterVersion = FakeFlutterVersion(channel: 'unknown');
fileSystem.currentDirectory.childFile('.flutter_tool_state')
.writeAsStringSync('{"last-active-master-version":"invalid"}');
final DowngradeCommand command = DowngradeCommand(
......@@ -52,7 +50,7 @@ void main() {
processManager: processManager,
terminal: terminal,
stdio: mockStdio,
flutterVersion: flutterVersion,
flutterVersion: fakeFlutterVersion,
logger: bufferLogger,
);
......@@ -61,7 +59,7 @@ void main() {
});
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')
.writeAsStringSync('{"last-active-master-version":"abcd"}');
final DowngradeCommand command = DowngradeCommand(
......@@ -77,7 +75,7 @@ void main() {
]),
terminal: terminal,
stdio: mockStdio,
flutterVersion: flutterVersion,
flutterVersion: fakeFlutterVersion,
logger: bufferLogger,
);
......@@ -90,7 +88,7 @@ void main() {
});
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')
.writeAsStringSync('{"last-active-master-version":"invalid"}');
final DowngradeCommand command = DowngradeCommand(
......@@ -105,7 +103,7 @@ void main() {
]),
terminal: terminal,
stdio: mockStdio,
flutterVersion: flutterVersion,
flutterVersion: fakeFlutterVersion,
logger: bufferLogger,
);
......@@ -114,7 +112,7 @@ void main() {
});
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);
fileSystem.currentDirectory.childFile('.flutter_tool_state')
.writeAsStringSync('{"last-active-master-version":"g6b00b5e88"}');
......@@ -123,7 +121,7 @@ void main() {
processManager: processManager,
terminal: terminal,
stdio: mockStdio,
flutterVersion: flutterVersion,
flutterVersion: fakeFlutterVersion,
logger: bufferLogger,
);
......@@ -144,7 +142,7 @@ void main() {
});
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);
fileSystem.currentDirectory.childFile('.flutter_tool_state')
.writeAsStringSync('{"last-active-master-version":"g6b00b5e88"}');
......@@ -153,7 +151,7 @@ void main() {
processManager: processManager,
terminal: terminal,
stdio: mockStdio,
flutterVersion: flutterVersion,
flutterVersion: fakeFlutterVersion,
logger: bufferLogger,
);
......@@ -174,7 +172,7 @@ void main() {
});
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);
fileSystem.currentDirectory.childFile('.flutter_tool_state')
.writeAsStringSync('{"last-active-master-version":"g6b00b5e88"}');
......@@ -186,7 +184,7 @@ void main() {
processManager: processManager,
terminal: terminal,
stdio: mockStdio,
flutterVersion: flutterVersion,
flutterVersion: fakeFlutterVersion,
logger: bufferLogger,
);
......@@ -201,7 +199,7 @@ void main() {
});
testUsingContext('Downgrade performs correct git commands', () async {
when(flutterVersion.channel).thenReturn('master');
final FakeFlutterVersion fakeFlutterVersion = FakeFlutterVersion(channel: 'master');
when(mockStdio.hasTerminal).thenReturn(false);
fileSystem.currentDirectory.childFile('.flutter_tool_state')
.writeAsStringSync('{"last-active-master-version":"g6b00b5e88"}');
......@@ -230,7 +228,7 @@ void main() {
]),
terminal: terminal,
stdio: mockStdio,
flutterVersion: flutterVersion,
flutterVersion: fakeFlutterVersion,
logger: bufferLogger,
);
......
......@@ -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/ios/devices.dart';
import 'package:flutter_tools/src/project.dart';
import 'package:flutter_tools/src/version.dart';
import 'package:mockito/mockito.dart';
import 'package:process/process.dart';
......@@ -235,4 +234,3 @@ class MockStdIn extends Mock implements IOSink {
}
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