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

Basic unit test to go through all the cobra related code #1835

Merged
merged 3 commits into from
Mar 20, 2019

Conversation

dgageot
Copy link
Contributor

@dgageot dgageot commented Mar 19, 2019

Signed-off-by: David Gageot [email protected]

testutil.CheckError(t, false, err)
testutil.CheckContains(t, "Available Commands", output.String())
testutil.CheckDeepEqual(t, "", errOutput.String())
}
Copy link
Member

Choose a reason for hiding this comment

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

Can we also have a test case for invalid command and see if error is returned.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tejal29 woot! Discovered a race condition thanks to this test

@codecov-io
Copy link

codecov-io commented Mar 19, 2019

Codecov Report

Merging #1835 into master will decrease coverage by 0.07%.
The diff coverage is 6.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1835      +/-   ##
==========================================
- Coverage   47.98%   47.91%   -0.08%     
==========================================
  Files         143      144       +1     
  Lines        6483     6499      +16     
==========================================
+ Hits         3111     3114       +3     
- Misses       3089     3101      +12     
- Partials      283      284       +1
Impacted Files Coverage Δ
cmd/skaffold/app/cmd/cmd.go 0% <0%> (ø) ⬆️
cmd/skaffold/app/cmd/completion.go 0% <0%> (ø) ⬆️
cmd/skaffold/app/skaffold.go 60% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8418c9e...c48c484. Read the comment docs.

rootCmd.PersistentPreRunE = func(cmd *cobra.Command, args []string) error {
if err := SetUpLogs(err, v); err != nil {
return err
}
rootCmd.SilenceUsage = true
logrus.Infof("Skaffold %+v", version.Get())

// Avoid race condition
Copy link
Member

Choose a reason for hiding this comment

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

Can you describe what race condition is it avoiding for dummies like me?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm going to simplify the code so that this is not needed anymore.

Copy link
Member

@tejal29 tejal29 left a comment

Choose a reason for hiding this comment

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

accept one nit to describe the race condition

@dgageot dgageot merged commit 2e4c4a9 into GoogleContainerTools:master Mar 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants