-
Notifications
You must be signed in to change notification settings - Fork 244
[Test] Test coverage in build #17
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] Test coverage in build #17
Conversation
Deals with #1 |
Wow. Thanks a lot! You are crazy 😄 |
Alright. As far as it gets. 92.5%. It's done. :) |
Hang on.. I might have another one. |
Yep. Done. :) 96.2%. All important path are covered including build failure. Now it can be refactored. |
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.
Ah sorry @Skarlso. Overlooked your refactoring part 😕
I hope you don't mind my comments.
@@ -18,6 +18,8 @@ const ( | |||
srcFolder = "src" | |||
) | |||
|
|||
var execCommandContext = exec.CommandContext |
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.
What is the benefit of storing this as an extra variable?
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.
The benefit is being able to mock exec.Command and test things like timeout in context and various exec error conditions later on should they arise. :)
pipeline/build_golang_test.go
Outdated
if err != nil { | ||
t.Fatal("error while running executebuild. none was expected") | ||
} | ||
expectedArgs := "-test.run=TestExecCommandContextHelper,--,/usr/local/bin/go,get,-d,./...:-test.run=TestExecCommandContextHelper,--,/usr/local/bin/go,build,-o,_" |
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.
If the go binary is not located at /usr/local/bin/ the test will fail.
What do you think about looking up the binary path programmatically? 🤓
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.
True. I have to put this into a contains string rather than this. :)
pipeline/build_golang_test.go
Outdated
if err == nil { | ||
t.Fatal("error while running executebuild. none was expected") | ||
} | ||
expected := `# _/Users/gbrautigam/gohome/src/github.com/gaia-pipeline/gaia/pipeline/tmp |
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 works only on your computer 😄
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.
Ah, wth. I left that in. :/ Bad me. :( Thanks. :)
@michelvocks Of course not! Please do so if you spot errors. :) |
A little cleanup is necessary but this is a good first start.
Coverage increased to 85.2%. ;) I want to add a little more coverage to the error cases. But I'm sleepy. :)