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
Conversation
@@ -445,6 +447,152 @@ class FakePub extends Fake implements Pub { | |||
}) async { } | |||
} | |||
|
|||
class FakeFlutterVersion implements FlutterVersion { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
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