-
Notifications
You must be signed in to change notification settings - Fork 242
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
[Test] Provide a dummy implementation for virtualMachine object for writing unit tests #4407
Comments
Would it be enough to be able to override |
@cfergeau : Yes, that can satisfy my use case. Do you have some examples of how I can achieve that? Perhaps you could share some old pull requests where the team might have added something close to this? |
@lstocchi did something similar in vfkit unit tests recently, he should be able to help with that. |
@rohanKanojia I joined recently and I didn't have the time to look at the crc project yet so I'm not really able to tell you if what I did is suitable for your use case. You can find the code here crc-org/vfkit@41e879f . Basically I had to test cloud-init to see if the configuration file was actually read. So I created a fedora machine, mount an image containing the config file, started the vm and interacted with it to verify everything was set accordingly. |
What I had in mind is the code where you use a function variable to be able to mock a function in a test, I forgot where it is exactly :) |
Could someone please assign this issue to me? |
Done! |
Component
Internal Testing Utilities
Description
Originally discussed in internal chat
Currently, there are not many unit tests in
pkg/crc/machine
module, probably due to the code dealing directly with managing virtual machines. It makes writing unit tests for CRC start, stop, and delete a bit difficult.I think we can add some dummy mock implementation for this
virtualMachine
object that can be used while writing unit tests. It can store the state of thevirtualMachine
as some variable that we can expose in tests to assert whether CRC was able to modify the state of VirtualMachine after performing some action (Stop, Start, Delete, etc).Gerard said they had something like a null driver in minishift codebase that could be used in the tests. Not 100% sure whether this is the correct reference: minishift@pkg/minishift/provisioner/minishift_provisioner_test.go
Acceptance Criteria
The text was updated successfully, but these errors were encountered: