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

Function TestNewJSONMetadataOperationResults

cmd/output_test.go:842–875  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

840}
841
842func 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
877func TestRenderCommandErrorInvalidOutputFormatFallsBackToText(t *testing.T) {
878 var stdout bytes.Buffer

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected