-
Notifications
You must be signed in to change notification settings - Fork 372
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
Add basic integration tests #203
Add basic integration tests #203
Conversation
integration/integration_test.go
Outdated
validPlugin = "konfig" | ||
) | ||
|
||
func TestInstall(t *testing.T) { |
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 before these, maybe we should try more fundamental things like exit codes, -h/—help working, unknown subcmds failing, Wdyt? I can go ahead and merge this, and iterate later as well.
integration/integration_test.go
Outdated
krewTest.WithIndex().Cmd("install", validPlugin).RunOrFailOutput() | ||
krewTest.Cmd("remove", validPlugin).RunOrFailOutput() | ||
|
||
indexFiles, err := krewTest.TempDir().List("store") |
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 this is fundamentally testing the wrong thing. It’s testing the implementation detail and not the user contract.
Once you uninstall a plugin these should happen and we should test them instead.
- Kubectl-foo no longer in PATH
- Krew list shows it as uninstalled
- Krew info fails
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.
You are totally right here.
Ideally next time please send a much smaller PR (maybe 1 test case) but focus on how we structure the test and how we integrate to travis. That provides a baseline with code that is already used, so we can iterate on it. 😊 |
@ahmetb Thanks for your feedback, that's exactly what I was hoping for. I think for going forward, I will remove the flawed test cases and add the very basic More test cases should follow in a separate PR. That should be straightforward to write down when everything else is set up. |
For faster tests, the index is only cloned once per test run. Additionally, the index is peristently cached between test runs.
Also, optionally link to a krew binary as specified via the KREW_BINARY env varible.
7ae85af
to
234c00b
Compare
234c00b
to
14c10ad
Compare
Note: marking as ready for review to enable travis, but this is still WIP. |
pkg/testutil/tempdir.go
Outdated
|
||
// List lists all the files in the subpath of the temp directory. | ||
// The input path is expected to use '/' as directory separator regardless of the host OS. | ||
func (td *TempDir) List(path string) ([]string, error) { |
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.
seems redundant now. feel free to remove.
/approve |
This is important, because importing the URI in integration tests triggers the init functions in the cmd package. This has very nasty and hard to find side-effects.
- rename package integration -> test - disable integration tests in run-tests.sh - remove obsolete tempdir helper
- Use a script run-integration-tests.sh for that - Add instructions how to run this script locally
c475327
to
bb48224
Compare
@ahmetb There was a little more work needed. But now the integration tests run on travis 🎉 🎊 |
moving this forward. will open an issue about removing |
[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 <ahmetb@google.com>
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 <ahmetb@google.com>
This is the beginning of integration tests for krew. It's in early stages and more tests need to be added, but the general look and feel should be clear. Therefore I'm eager to get some feedback what should be improved. In particular, there's some aggressive caching of the krew-index clone.
Additionally, I haven't thought about how these tests are run on Travis. That needs to be sorted out as well.