k3s/pkg/kubectl/cmd/testdata/edit
Kubernetes Submit Queue 577fdf91c2 Merge pull request #50205 from dixudx/fix_kubectl_edit_panic_nil_list
Automatic merge from submit-queue (batch tested with PRs 50537, 49699, 50160, 49025, 50205)

not allowing "kubectl edit <resource>" when you got an empty list

**What this PR does / why we need it**:
`kubectl edit` will panic when adding an empty list.

> panic: runtime error: index out of range

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #50147

**Special notes for your reviewer**:
/assign @errordeveloper @mengqiy @janetkuo @fabianofranz
/cc @rootfs @soltysh @sttts

**Release note**:

```release-note
not allowing "kubectl edit <resource>" when you got an empty list
```
2017-08-11 19:44:04 -07:00
..
testcase-apply-edit-last-applied update related files 2017-07-25 12:56:50 +08:00
testcase-apply-edit-last-applied-list update related files 2017-07-25 12:56:50 +08:00
testcase-apply-edit-last-applied-syntax-error update related files 2017-07-25 12:56:50 +08:00
testcase-create-list
testcase-create-list-error
testcase-edit-error-reedit support setElementOrder 2017-05-31 15:08:25 -07:00
testcase-edit-from-empty forbid kubectl edit an empty list 2017-08-11 08:44:13 +08:00
testcase-edit-output-patch allow output patch string in edit command 2017-06-01 14:53:17 +08:00
testcase-immutable-name
testcase-list support setElementOrder 2017-05-31 15:08:25 -07:00
testcase-list-errors support setElementOrder 2017-05-31 15:08:25 -07:00
testcase-list-record support setElementOrder 2017-05-31 15:08:25 -07:00
testcase-missing-service
testcase-no-op
testcase-not-update-annotation support setElementOrder 2017-05-31 15:08:25 -07:00
testcase-repeat-error
testcase-schemaless-list
testcase-single-service support setElementOrder 2017-05-31 15:08:25 -07:00
testcase-syntax-error
testcase-unknown-field-known-group-kind
testcase-unknown-version-known-group-kind
testcase-update-annotation support setElementOrder 2017-05-31 15:08:25 -07:00
BUILD Use buildozer to delete licenses() rules except under third_party/ 2017-08-11 09:32:39 -07:00
README
record.go
record_editor.sh
record_testcase.sh
test_editor.sh

README

This folder contains test cases for interactive edit, and helpers for recording new test cases

To record a new test:

1. Start a local cluster running unsecured on http://localhost:8080 (e.g. hack/local-up-cluster.sh)
2. Set up any pre-existing resources you want to be available on that server (namespaces, resources to edit, etc)
3. Run ./pkg/kubectl/cmd/testdata/edit/record_testcase.sh my-testcase
4. Run the desired `kubectl edit ...` command, and interact with the editor as desired until it completes.
  * You can do things that cause errors to appear in the editor (change immutable fields, fail validation, etc)
  * You can perform edit flows that invoke the editor multiple times
  * You can make out-of-band changes to the server resources that cause conflict errors to be returned
  * The API requests/responses and editor inputs/outputs are captured in your testcase folder
5. Type exit.
6. Inspect the captured requests/responses and inputs/outputs for sanity
7. Modify the generated test.yaml file:
  * Set a description of what the test is doing
  * Enter the args (if any) you invoked edit with
  * Enter the filename (if any) you invoked edit with
  * Enter the output format (if any) you invoked edit with
  * Optionally specify substrings to look for in the stdout or stderr of the edit command
8. Add your new testcase name to the list of testcases in edit_test.go
9. Run `go test ./pkg/kubectl/cmd -run TestEdit -v` to run edit tests