-
Notifications
You must be signed in to change notification settings - Fork 5
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
Improve how we use git in eext and improve the code's testing facilities. #152
base: main
Are you sure you want to change the base?
Conversation
The purpose of the function was missing, and the comment grammar implied that only the pull is being done.
There was a lot of boiler plate that was hard to follow, so this patch introduces a simple list of git commands to run. It should also yield potentially better error messages in case of a failure.
4a3212b
to
7f5bb57
Compare
"code.arista.io/eos/tools/eext/util" | ||
"github.com/spf13/viper" | ||
"github.com/stretchr/testify/require" | ||
//"code.arista.io/eos/tools/eext/executor/mocked_executor" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment can be removed
// MockedExecutor returns the Response objects for each of the MockedExecutor | ||
// calls. The responses are consumed in the natural order, meaning [0] is the | ||
// first one to be returned. | ||
Responses []Response |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we consider making this a struct of Call and Response.
type MockedExecutor struct {
MockedEntries []struct{
Response Response
Call RecordedCall
}
}
Currently the onus of maintaining the order of Response is on the dev, and I feel the mapping might get messier with longer Response slices.
if err != nil { | ||
t.Fatal(err) | ||
mex := executor.MockedExecutor{ | ||
Responses: []executor.Response{executor.NewResponse(0, "libpcap-1.10.1", nil)}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This Response is the mocked output for the call
rpmName, err := executor.Output("rpmspec", cmd...)
within the getRpmNameFromSpecFile()
.
But that isn't evident here.
Furthermore a reason to have a struct of Call and Response for easier readability.
@@ -15,7 +15,7 @@ type DryRunExecutor struct { | |||
// extra abstractions feel unnecessary. | |||
|
|||
// human friendly description of what an invocation would do | |||
invocations []string | |||
Invocations []string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We aren't using this member outside this file. Do we need to export it?
Previously the tests for code that sourced packages with git was downloading actual repositories. This PR rearranges the code a bit to make it more testable, introduces a simple executor mock, and uses it, making the whole process more contained.
It also has a small fix (97b67a2) that properly handles commits used as revisions. The new tests also cover this logic path.