MCPcopy Create free account
hub / github.com/dropbox/dbxcli / TestLsRejectsInvalidListOptions

Function TestLsRejectsInvalidListOptions

cmd/ls_test.go:483–517  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

481}
482
483func TestLsRejectsInvalidListOptions(t *testing.T) {
484 tests := []struct {
485 name string
486 flag string
487 value string
488 }{
489 {name: "sort", flag: "sort", value: "date"},
490 {name: "time", flag: "time", value: "created"},
491 {name: "time-format", flag: "time-format", value: "unix"},
492 }
493
494 for _, tt := range tests {
495 t.Run(tt.name, func(t *testing.T) {
496 cmd, stdout := testLsCmd(t)
497 setLsFlag(t, cmd, tt.flag, tt.value)
498 stubFilesClient(t, &mockFilesClient{
499 listFolderFn: func(arg *files.ListFolderArg) (*files.ListFolderResult, error) {
500 t.Fatalf("ListFolder called for invalid --%s", tt.flag)
501 return nil, nil
502 },
503 })
504
505 err := ls(cmd, nil)
506 if err == nil {
507 t.Fatalf("expected invalid --%s error", tt.flag)
508 }
509 if !strings.Contains(err.Error(), tt.flag) || !strings.Contains(err.Error(), tt.value) {
510 t.Fatalf("error = %v, want flag and value", err)
511 }
512 if got := stdout.String(); got != "" {
513 t.Fatalf("stdout = %q, want empty output on validation error", got)
514 }
515 })
516 }
517}
518
519func TestLsJSONFilePathUsesMetadata(t *testing.T) {
520 cmd, stdout := testLsCmd(t)

Callers

nothing calls this directly

Calls 5

testLsCmdFunction · 0.85
setLsFlagFunction · 0.85
stubFilesClientFunction · 0.85
lsFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected