(t *testing.T)
| 518 | } |
| 519 | |
| 520 | func 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 | |
| 547 | func TestJSONHelpDoesNotRequireAuth(t *testing.T) { |
| 548 | t.Setenv(envAccessToken, "") |
nothing calls this directly
no test coverage detected