isCompletionCommand must classify BOTH cobra completion aliases as completion requests so the Shutdown emit and update-notice paths skip shell-completion invocations. __completeNoDesc is an Alias of __complete (cobra/completions.go ShellCompNoDescRequestCmd) and dispatches the same RunE; bash/zsh co
(t *testing.T)
| 119 | // dispatches the same RunE; bash/zsh completion typically calls the |
| 120 | // NoDesc variant. |
| 121 | func TestIsCompletionCommand(t *testing.T) { |
| 122 | tests := []struct { |
| 123 | name string |
| 124 | args []string |
| 125 | want bool |
| 126 | }{ |
| 127 | {"plain command", []string{"im", "+send"}, false}, |
| 128 | {"__complete", []string{"__complete", "im"}, true}, |
| 129 | {"__completeNoDesc", []string{"__completeNoDesc", "im"}, true}, |
| 130 | {"completion subcommand", []string{"completion", "bash"}, true}, |
| 131 | {"completion in tail", []string{"foo", "bar", "completion"}, true}, |
| 132 | } |
| 133 | for _, tc := range tests { |
| 134 | t.Run(tc.name, func(t *testing.T) { |
| 135 | if got := isCompletionCommand(tc.args); got != tc.want { |
| 136 | t.Fatalf("isCompletionCommand(%v) = %v, want %v", tc.args, got, tc.want) |
| 137 | } |
| 138 | }) |
| 139 | } |
| 140 | } |
| 141 | |
| 142 | // TestHandleRootError_SecurityPolicyCanonicalEnvelope verifies that |
| 143 | // *errs.SecurityPolicyError flows through the canonical typed envelope |
nothing calls this directly
no test coverage detected