(t *testing.T)
| 840 | } |
| 841 | |
| 842 | func TestNewJSONMetadataOperationResults(t *testing.T) { |
| 843 | size := uint64(42) |
| 844 | results := newJSONMetadataOperationResults("listed", []jsonMetadata{ |
| 845 | { |
| 846 | Type: "file", |
| 847 | PathDisplay: "/file.txt", |
| 848 | Size: &size, |
| 849 | }, |
| 850 | { |
| 851 | Type: "folder", |
| 852 | PathDisplay: "/folder", |
| 853 | }, |
| 854 | }) |
| 855 | |
| 856 | if len(results) != 2 { |
| 857 | t.Fatalf("results = %d, want 2", len(results)) |
| 858 | } |
| 859 | if results[0].Status != "listed" || results[0].Kind != "file" { |
| 860 | t.Fatalf("first result = %#v, want listed file", results[0]) |
| 861 | } |
| 862 | if _, ok := results[0].Input.(struct{}); !ok { |
| 863 | t.Fatalf("first result input = %#v, want empty object", results[0].Input) |
| 864 | } |
| 865 | first, ok := results[0].Result.(jsonMetadata) |
| 866 | if !ok { |
| 867 | t.Fatalf("first result metadata type = %T, want jsonMetadata", results[0].Result) |
| 868 | } |
| 869 | if first.PathDisplay != "/file.txt" || first.Size == nil || *first.Size != 42 { |
| 870 | t.Fatalf("first metadata = %#v, want file metadata", first) |
| 871 | } |
| 872 | if results[1].Status != "listed" || results[1].Kind != "folder" { |
| 873 | t.Fatalf("second result = %#v, want listed folder", results[1]) |
| 874 | } |
| 875 | } |
| 876 | |
| 877 | func TestRenderCommandErrorInvalidOutputFormatFallsBackToText(t *testing.T) { |
| 878 | var stdout bytes.Buffer |
nothing calls this directly
no test coverage detected