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

Function TestValidArgsGetCategory

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

Source from the content-addressed store, hash-verified

210}
211
212func TestValidArgsGetCategory(t *testing.T) {
213 type args struct {
214 in0 *cobra.Command
215 args []string
216 toComplete string
217 }
218 tests := []struct {
219 name string
220 args args
221 want assert.Want[[]string]
222 want1 cobra.ShellCompDirective
223 }{
224 {
225 name: "no arg - return catalog",
226 args: args{
227 toComplete: "",
228 },
229 want: func(t *testing.T, got []string) bool {
230 return assert.Contains(t, got, fmt.Sprintf("%s\t%s: %s", testdata.MockCatalogID, testdata.MockCatalogName, testdata.MockCatalogDescription))
231 },
232 want1: cobra.ShellCompDirectiveNoFileComp,
233 },
234 {
235 name: "one arg - return category",
236 args: args{
237 args: []string{testdata.MockCatalogID},
238 toComplete: "",
239 },
240 want: func(t *testing.T, got []string) bool {
241 return assert.Contains(t, got, fmt.Sprintf("%s\t%s", testdata.MockCategoryName, testdata.MockCategoryDescription))
242 },
243 want1: cobra.ShellCompDirectiveNoFileComp,
244 },
245 {
246 name: "all args - return nothing",
247 args: args{
248 args: []string{testdata.MockCatalogID, testdata.MockCategoryName},
249 toComplete: "",
250 },
251 want: assert.Empty[[]string],
252 want1: cobra.ShellCompDirectiveNoFileComp,
253 },
254 }
255
256 for _, tt := range tests {
257 t.Run(tt.name, func(t *testing.T) {
258 got, got1 := cli.ValidArgsGetCategory(tt.args.in0, tt.args.args, tt.args.toComplete)
259 tt.want(t, got)
260 assert.Equal(t, tt.want1, got1)
261 })
262 }
263}
264
265func TestValidArgsGetControls(t *testing.T) {
266 type args struct {

Callers

nothing calls this directly

Calls 2

ValidArgsGetCategoryFunction · 0.92
EqualFunction · 0.92

Tested by

no test coverage detected