-
Notifications
You must be signed in to change notification settings - Fork 369
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
More integration tests #208
More integration tests #208
Conversation
11d8700
to
31d3f2f
Compare
Codecov Report
@@ Coverage Diff @@
## master #208 +/- ##
=======================================
Coverage 53.77% 53.77%
=======================================
Files 13 13
Lines 716 716
=======================================
Hits 385 385
Misses 279 279
Partials 52 52 Continue to review full report at Codecov.
|
Missing subcommand: upgrade
0 plugins -> empty string (instead of 2 lines) 1 plugin -> 1 line (instead of 2 lines) 2 plugins -> 2 lines (instead of 3 lines)
31d3f2f
to
356a9ee
Compare
8d1a336
to
e73978c
Compare
test/krew_test.go
Outdated
if string(in) == "" { | ||
return nil | ||
} | ||
return strings.Split(string(in), "\n") |
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.
ideally you should do strings.TrimRight(string(in))
so that you avoid taking trailing \n
which almost all commands will have.
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.
with this, you don't need the =="" check,
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.
Unfortunately, the ==""
is still required. For krew list
I need the list of results to grow by one if a plugin is installed. However, when starting from none (resulting in "\n") to one plugin ("whatever\n") would result in 1 entry each.
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.
hmm. I'm not sure if that's accurate.
Since in this case the stdout is not a tty, we don't print the tabular output.
I expect no output or at most \n
. Both of which would return []string{}
(len=0).
When you install a plugin I expect this to return pluginname\n
, if you split it by \n
it should return []string{"pluginnname"}
(len=1).
Alternatively you can also test that case as output.Contains("pluginname")
, which is also just fine.
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.
I expect no output or at most
\n
. Both of which would return[]string{}
(len=0).
That is unfortunately not the case. If the input string is empty or "\n", it will result in []string{""}
.
test/krew_test.go
Outdated
"ExecutedVersion", | ||
"GitTag", | ||
"GitCommit", | ||
"IndexURI https://github.com/kubernetes-sigs/krew-index.git", |
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.
I feel like we'll easily break these spaces. :)
I'm not sure if this whole thing is necessary. I currently only care about exitcode=0. :)
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.
I think it's worth a lot to know if something is present in the output. Do you like a regex-based assertion better?
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.
I think anything is fine.
- clarify logic for `krew list` test - check error case for `krew info` - make `krew version` test more resilient against formatting changes
test/krew_test.go
Outdated
plugin string | ||
shouldErr bool | ||
}{ | ||
{ |
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.
please don't put negative cases to the same test case.
they are different test cases. and these aren't unit tests. tabular tests like []struct{}{} are good for tabular unit tests. but ideally each integration test case should be a separate method testing a particular scenario workflow.
e.g. try
TestKrewInfo
TestKrewInfoInvalidPlugin
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.
Makes sense. The test cases are not split into separate test functions.
I recommend removing the WIP label so we can move forward with merging. |
The WIP label should already have been gone for a while. At least I don't see it any longer. |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ahmetb, corneliusweig The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Adding corneliusweig to owners. He has been consistently helping both with krew and krew-index repositories in terms of: - developing plugins himself - taking a stab at krew machinery with large scale code refactors - adding integration test suite to the project - adding more validation and test cases - increasing developer documentation Some of his notable work: - kubernetes-sigs#195 - kubernetes-sigs#183 - kubernetes-sigs#191 - kubernetes-sigs#201 - kubernetes-sigs#202 - kubernetes-sigs#203 - kubernetes-sigs#208 He is familiar with the codebase enough to officially review and approve code. Signed-off-by: Ahmet Alp Balkan <[email protected]>
Adding corneliusweig to owners. He has been consistently helping both with krew and krew-index repositories in terms of: - developing plugins himself - taking a stab at krew machinery with large scale code refactors - adding integration test suite to the project - adding more validation and test cases - increasing developer documentation Some of his notable work: - #195 - #183 - #191 - #201 - #202 - #203 - #208 He is familiar with the codebase enough to officially review and approve code. Signed-off-by: Ahmet Alp Balkan <[email protected]>
These are based on #203 and should be merged after that one. Reviewing before #203 is merged makes also no sense :-/
The tests currently cover the happy path of all subcommands excluding
krew upgrade
. Upgrade is a special case because it needs two versions of a valid plugin. That will be difficult to set up and may be better in a separate PR.