Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[flutter_tools] switch FakeCache to cache.test and NoopUsage to TestUsage #76802

Merged
merged 3 commits into from Feb 26, 2021

Conversation

jonahwilliams
Copy link
Member

To reduce the number of fakes used for classes where we've already created a test implementation. Also move the fakes from the testbed lib into fakes.dart

@flutter-dashboard flutter-dashboard bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Feb 25, 2021
@google-cla google-cla bot added the cla: yes label Feb 25, 2021
@jonahwilliams jonahwilliams changed the title [flutter_tools] switch fakecache to cache.test and noop usage to test usage [flutter_tools] switch FakeCache to cache.test and NoopUsage to TestUsage Feb 26, 2021
@@ -445,6 +447,152 @@ class FakePub extends Fake implements Pub {
}) async { }
}

class FakeFlutterVersion implements FlutterVersion {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know you just moved this, but this test class doesn't seem tight enough considering it's not actually a Fake and the FlutterVersion constructor is calling git commands.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, thankfully its not widely used so we should probably find a better pattern.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh nm it's an implements, does this work if you extends Fake?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FlutterVersion was one of the most painful to inject into tests because of those git calls.

FlutterVersion flutterVersion, // Instantiating FlutterVersion kicks off networking, so delay until it's needed, but allow test injection.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I mean is that I agree we should fix this, but I think since this PR didn't actually modify it (and it is still default injected in the testbed groups) I don't think I should expand the scope of this PR to also fix it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just checked, the tests pass with:

class TestFeatureFlags extends Fake implements FeatureFlags {
class FakeFlutterVersion extends Fake implements FlutterVersion {

I know you just moved this, but

I think since this PR didn't actually modify it I don't think I should expand the scope of this PR to also fix it.

Fair enough. I can play with it if I adopt FakeFlutterVersion in more places.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TestFeatureFlags definitely isn't a fake though, its pretty specifically designed

Copy link
Member

@jmagman jmagman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jonahwilliams jonahwilliams merged commit 2951363 into flutter:master Feb 26, 2021
@jonahwilliams jonahwilliams deleted the remove_test_bed branch February 26, 2021 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tool Affects the "flutter" command-line tool. See also t: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants