-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: mocks LimaUser to fix race condition in support bundle unit tes…
…ts (#450) Issue #, if available: #447 *Description of changes:* There was a race condition in the unit tests for `support-bundle generate` caused by Lima's `osutil.LimaUser` not being thread-safe. I don't think there's really a need to make it thread-safe, so I think it's easier to just wrap and mock it for the unit tests, which I've done here. *Testing done:* ``` make test-unit ``` - [x] I've reviewed the guidance in CONTRIBUTING.md #### License Acceptance By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. Signed-off-by: Sam Berning <[email protected]>
- Loading branch information
1 parent
96fc8d0
commit 9f4b87c
Showing
5 changed files
with
146 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// Package wrapper provides an interface to wrap Lima utils | ||
package wrapper | ||
|
||
import ( | ||
"os/user" | ||
|
||
"github.com/lima-vm/lima/pkg/osutil" | ||
) | ||
|
||
// LimaWrapper provides Lima utils in an interface to facilitate mocking | ||
// | ||
//go:generate mockgen --destination=../../mocks/lima_wrapper.go -package=mocks github.com/runfinch/finch/pkg/lima/wrapper LimaWrapper | ||
type LimaWrapper interface { | ||
LimaUser(warn bool) (*user.User, error) | ||
} | ||
|
||
type limaWrapper struct{} | ||
|
||
// NewLimaWrapper returns a new LimaWrapper. | ||
func NewLimaWrapper() LimaWrapper { | ||
return &limaWrapper{} | ||
} | ||
|
||
// LimaUser returns the user that will be used inside the Lima VM. | ||
func (*limaWrapper) LimaUser(warn bool) (*user.User, error) { | ||
return osutil.LimaUser(warn) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters