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

limayaml/defaults_test.go: use slices.Clone() to create expect variable #2587

Merged
merged 4 commits into from
Sep 4, 2024

Conversation

norio-nomura
Copy link
Contributor

to avoid input variable were changed on preparing expect variable.

Also fixes some tests that passed unexpectedly because input variable was changed.

pkg/limayaml/defaults_test.go Outdated Show resolved Hide resolved
pkg/limayaml/defaults_test.go Show resolved Hide resolved
…riable

to avoid input variable were changed on preparing `expect` variable.

Signed-off-by: Norio Nomura <norio.nomura@gmail.com>

limayaml: revert fixing expect

Signed-off-by: Norio Nomura <norio.nomura@gmail.com>
The test was passing regardless of what value was assigned to `Script` because `expect.Probes[0]` and `y.Probes[0]` were the same instance.

Signed-off-by: Norio Nomura <norio.nomura@gmail.com>
…ueueSize`

`expect.Mounts[0]` was the same instance as each of `y.Mounts[0]` and `d.Mounts[0]`, so the test passed regardless of the value set for `Virtiofs.QueueSize`.
The default for `Virtiofs.QueueSize` is `nil`, but I'll keep the code that explicitly sets it to `nil` to make it clear that `nil` is expected.

Signed-off-by: Norio Nomura <norio.nomura@gmail.com>
Because `d` is no longer modified to expected values, it needs to keep `dExpect` to creating `expect` variable later.

Signed-off-by: Norio Nomura <norio.nomura@gmail.com>
Copy link
Member

@jandubois jandubois left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM

@jandubois jandubois merged commit 2eb8b2f into lima-vm:master Sep 4, 2024
27 checks passed
@norio-nomura
Copy link
Contributor Author

Thanks! 🙏🏻

@norio-nomura norio-nomura deleted the use-slices-Clone branch September 4, 2024 05:50
@nirs
Copy link
Member

nirs commented Sep 4, 2024

This is so much nicer like this! every change has a clear commit message explaining the change and if we need to revert a change it can be a simple revert of single commit.

Regrading the actual it seems that if we need to clone so many things, we can simplify by deep copying the entire struct.

@AkihiroSuda AkihiroSuda added this to the v1.0 milestone Sep 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants