MCPcopy Create free account
hub / github.com/clouditor/clouditor / TestValidArgsGetControls

Function TestValidArgsGetControls

cli/session_test.go:265–327  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

263}
264
265func TestValidArgsGetControls(t *testing.T) {
266 type args struct {
267 in0 *cobra.Command
268 args []string
269 toComplete string
270 }
271 tests := []struct {
272 name string
273 args args
274 want assert.Want[[]string]
275 want1 cobra.ShellCompDirective
276 }{
277 {
278 name: "no arg - return catalog",
279 args: args{
280 toComplete: "",
281 },
282 want: func(t *testing.T, got []string) bool {
283 return assert.Contains(t, got, fmt.Sprintf("%s\t%s: %s", testdata.MockCatalogID, testdata.MockCatalogName, testdata.MockCatalogDescription))
284 },
285 want1: cobra.ShellCompDirectiveNoFileComp,
286 },
287 {
288 name: "one arg - return category",
289 args: args{
290 args: []string{testdata.MockCatalogID},
291 toComplete: "",
292 },
293 want: func(t *testing.T, got []string) bool {
294 return assert.Contains(t, got, fmt.Sprintf("%s\t%s", testdata.MockCategoryName, testdata.MockCategoryDescription))
295 },
296 want1: cobra.ShellCompDirectiveNoFileComp,
297 },
298 {
299 name: "two args - return category",
300 args: args{
301 args: []string{testdata.MockCatalogID, testdata.MockCategoryName},
302 toComplete: "",
303 },
304 want: func(t *testing.T, got []string) bool {
305 return assert.Contains(t, got, fmt.Sprintf("%s\t%s: %s", testdata.MockControlID1, testdata.MockControlName, testdata.MockControlDescription))
306 },
307 want1: cobra.ShellCompDirectiveNoFileComp,
308 },
309 {
310 name: "all args - return nothing",
311 args: args{
312 args: []string{testdata.MockCatalogID, testdata.MockCategoryName, testdata.MockControlID1},
313 toComplete: "",
314 },
315 want: assert.Empty[[]string],
316 want1: cobra.ShellCompDirectiveNoFileComp,
317 },
318 }
319
320 for _, tt := range tests {
321 t.Run(tt.name, func(t *testing.T) {
322 got, got1 := cli.ValidArgsGetControls(tt.args.in0, tt.args.args, tt.args.toComplete)

Callers

nothing calls this directly

Calls 2

ValidArgsGetControlsFunction · 0.92
EqualFunction · 0.92

Tested by

no test coverage detected