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

Function TestJSONHelpIsDeterministic

cmd/help_json_test.go:520–545  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

518}
519
520func TestJSONHelpIsDeterministic(t *testing.T) {
521 first, _, err := executeJSONHelpTestRoot(t, []string{"--help", "--output=json"})
522 if err != nil {
523 t.Fatalf("first Execute returned error: %v", err)
524 }
525 second, _, err := executeJSONHelpTestRoot(t, []string{"--output=json", "--help"})
526 if err != nil {
527 t.Fatalf("second Execute returned error: %v", err)
528 }
529 if first != second {
530 t.Fatalf("JSON help output differs between equivalent invocations\nfirst: %s\nsecond: %s", first, second)
531 }
532
533 got := decodeJSONHelpOutput(t, first)
534 for _, result := range got.Results {
535 var names []string
536 for _, flag := range result.Result.Flags {
537 names = append(names, flag.Name)
538 }
539 sorted := append([]string{}, names...)
540 sortStrings(sorted)
541 if !reflect.DeepEqual(names, sorted) {
542 t.Fatalf("flags for %s are not sorted: %v", result.Result.Path, names)
543 }
544 }
545}
546
547func TestJSONHelpDoesNotRequireAuth(t *testing.T) {
548 t.Setenv(envAccessToken, "")

Callers

nothing calls this directly

Calls 3

executeJSONHelpTestRootFunction · 0.85
decodeJSONHelpOutputFunction · 0.85
sortStringsFunction · 0.85

Tested by

no test coverage detected