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

[Feature Request] Tests: Mock system calls & expectations instead of using on local repo #273

Closed
ened opened this issue Apr 19, 2021 · 8 comments
Assignees
Labels
enhancement New feature or request wontfix This will not be worked on

Comments

@ened
Copy link
Contributor

ened commented Apr 19, 2021

Is your feature request related to a problem? Please describe.

Running the test suite currently causes actual downloads & install commands.

Describe the solution you'd like

The test suite should run the commands against a mock shell / mock environment. Commands & their responses could be recorded, mocked & evaluated.

Additional context

This implies a bit of refactor in how fvm runs the commands.
This probably has to go through a PlatformExecutor class or similar.

That class needs a test, but it will probably suffice to test echo 123 or similar.

@ened ened added the enhancement New feature or request label Apr 19, 2021
@leoafarias
Copy link
Owner

@ened I have a local reference flutter repo that I use as "mock" and makes things run much faster. Passing the local flutter repo as an env var FVM_GIT_CACHE. The tests run much quicker.

@leoafarias leoafarias self-assigned this Apr 19, 2021
@ened
Copy link
Contributor Author

ened commented Apr 19, 2021

@leoafarias Understood you have a local test repo.
Will this work on CI? Is this picked up simply by running flutter test?

Does the unit test actually need a repository? Wouldn't the commands be enough?

@leoafarias
Copy link
Owner

On the CI I run without the local cache since the time is not a priority. I implemented an AppContext in order to control them a bit more the tests as I get the coverage a bit higher. I do plan on creating a MockContext, that automatically creates/updates and uses a local referenced repo.

However, I am not if mocking so you don't need the repo is a good option. FVM does not work without a flutter repository. Would have to mock all flutter and git tools which are critical pieces.

@ened
Copy link
Contributor Author

ened commented Apr 20, 2021

@leoafarias agree you'd had to mock all of the interfaces with the file system & tools underneath.
This would document the tool invocations and any expectations as well.

@leoafarias
Copy link
Owner

@ened I am not opposed to have a better documented interface. However it seems that this was not the purpose of the initial issue.

  • Quicker tests
  • Download on every test run

These are addressed by the local reference in the mock local repo.

Do you want to update the goals of the issue, I think I can get aligned on the problem with you.

@ened ened changed the title [Feature Request] Quicker integration test [Feature Request] Tests: Mock system calls & expectations instead of using on local repo Apr 20, 2021
@ened
Copy link
Contributor Author

ened commented Apr 20, 2021

@leoafarias ok updated the title, hope that is sufficient to move on.

@leoafarias
Copy link
Owner

For future ticket reference:

  • I currently implemented AppContext in order to allow for some overrides, and better mocking.
  • Create abstractions mock services especially FlutterTools and GitTools

@stale
Copy link

stale bot commented Dec 2, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label Dec 2, 2022
@stale stale bot closed this as completed Dec 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants