add more boolean test cases

Signed-off-by: Artem Mikhalitsin <artemmikhalitsin@gmail.com>
pull/30614/head
Artem Mikhalitsin 10 months ago committed by Artem Mikhalitsin
parent 7d44a9eaf8
commit 1e981bdc52

@ -161,8 +161,8 @@ func processParent(cmd *cobra.Command, args []string) ([]string, error) {
// Returns two sets of args: known and unknown (in that order)
// Known args are flags that are consumed by the root `helm` command
// Unknown args are any args that will not be consumed by helm, and that may be
// processed by the plugin plus
// The single exception is -h or --help, which is passed to the plugin
// processed by the plugin
// The single exception is -h or --help, which is passed to the plugin regardless
func manuallyProcessArgs(args []string) ([]string, []string) {
known := []string{}
unknown := []string{}
@ -185,7 +185,7 @@ func manuallyProcessArgs(args []string) ([]string, []string) {
"--registry-config",
"--repository-cache",
"--repository-config"}
kvargs = append(kvargs, boolArgs...) // bool args can also by kv i.e. `--debug=true`
kvargs = append(kvargs, boolArgs...) // boolean args can also be kv i.e. `--debug=true`
// detects args with 'arg=val' syntax
isKnownKvWithEquals := func(a string) bool {

@ -36,11 +36,15 @@ func TestManuallyProcessArgs(t *testing.T) {
"--debug",
"--debug=true",
"--debug", "true",
"--debug", "1",
"--debug", "false",
"--debug", "0",
"--kube-insecure-skip-tls-verify",
"--kube-insecure-skip-tls-verify=true",
"--kube-insecure-skip-tls-verify", "true",
"--kube-insecure-skip-tls-verify", "1",
"--kube-insecure-skip-tls-verify", "false",
"--kube-insecure-skip-tls-verify", "0",
"--foo", "bar",
"--burst-limit", "123",
"--burst-limit=123",
@ -59,18 +63,22 @@ func TestManuallyProcessArgs(t *testing.T) {
"--qps=22",
"--home=/tmp",
"command",
"--debug", // check a boolean flag at the end to test possible out of bounds exception
"--debug", // test for possible out of bounds error when parsing boolean flags
}
expectKnown := []string{
"--debug",
"--debug=true",
"--debug", "true",
"--debug", "1",
"--debug", "false",
"--debug", "0",
"--kube-insecure-skip-tls-verify",
"--kube-insecure-skip-tls-verify=true",
"--kube-insecure-skip-tls-verify", "true",
"--kube-insecure-skip-tls-verify", "1",
"--kube-insecure-skip-tls-verify", "false",
"--kube-insecure-skip-tls-verify", "0",
"--burst-limit", "123",
"--burst-limit=123",
"--kubeconfig=/home/foo",

Loading…
Cancel
Save