Simplify LibraryContainer hierarchy and tests #4121
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This one is a bit of a story; I could break it up if that would help the review, but here goes:
abstract mixin class, was (a) mixed into Category, and (b) extended by Package. Weird. So I tried to make it a base class, a proper superclass of those two. Well that showed me the two test classes: TestLibraryContainer and TestLibraryContainerSdk.model_test.dart. These test cases just test thecompareTologic in LibraryContainer, but it is not terribly obvious how they test them. The TestLibraryContainer seemed very generic, and odd, with its own ContainerOrder list. In practice, Categories are always ordered by the--category-orderoption, and Packages are always ordered by the--package-orderoption. There's no need to test some generic ordering system.groupinpackages_test.dart.isSdkandenclosingNameto be simple, final fields on LibraryContainer, andenclosingNamecan be private. And thencontainerOrderonly needs to stay public in order to override.writePackagetest function: (a) it was writing a.packagesfile, and (b) it was writing hard-coded package names into a package config file. We fix this by passing in a list of dependency names.