(t *testing.T)
| 219 | } |
| 220 | |
| 221 | func TestCompleteAlias(t *testing.T) { |
| 222 | t.Parallel() |
| 223 | |
| 224 | tests := []struct { |
| 225 | name string |
| 226 | toComplete string |
| 227 | wantFilesystem bool // if true, should delegate to filesystem completion |
| 228 | }{ |
| 229 | { |
| 230 | name: "path starting with dot delegates to filesystem", |
| 231 | toComplete: "./agent", |
| 232 | wantFilesystem: true, |
| 233 | }, |
| 234 | { |
| 235 | name: "path starting with slash delegates to filesystem", |
| 236 | toComplete: "/etc/agent", |
| 237 | wantFilesystem: true, |
| 238 | }, |
| 239 | { |
| 240 | name: "plain text tries alias completion", |
| 241 | toComplete: "myalias", |
| 242 | wantFilesystem: false, |
| 243 | }, |
| 244 | } |
| 245 | |
| 246 | for _, tt := range tests { |
| 247 | t.Run(tt.name, func(t *testing.T) { |
| 248 | t.Parallel() |
| 249 | |
| 250 | _, directive := completeAlias(tt.toComplete) |
| 251 | |
| 252 | // Both paths should set NoFileComp |
| 253 | assert.NotEqual(t, cobra.ShellCompDirective(0), directive&cobra.ShellCompDirectiveNoFileComp, |
| 254 | "expected NoFileComp directive to be set") |
| 255 | }) |
| 256 | } |
| 257 | } |
| 258 | |
| 259 | func TestCompleteAliasIncludesYAMLFiles(t *testing.T) { |
| 260 | // This test changes the working directory so it cannot run in parallel |
nothing calls this directly
no test coverage detected