lsjson,lsf: make sure metadata appears for directories

This commit is contained in:
Nick Craig-Wood
2024-02-07 21:28:27 +00:00
parent e4d0055b3e
commit 09953d77b5
2 changed files with 22 additions and 9 deletions

View File

@@ -174,7 +174,7 @@ func TestListJSON(t *testing.T) {
}, {
name: "Metadata",
opt: operations.ListJSONOpt{
FilesOnly: true,
FilesOnly: false,
Metadata: true,
},
want: []*operations.ListJSONItem{{
@@ -183,6 +183,10 @@ func TestListJSON(t *testing.T) {
Size: 5,
ModTime: operations.Timestamp{When: t1},
IsDir: false,
}, {
Path: "sub",
Name: "sub",
IsDir: true,
}},
},
} {
@@ -203,6 +207,15 @@ func TestListJSON(t *testing.T) {
} else {
assert.NotEqual(t, "", got[i].MimeType)
}
if test.opt.Metadata {
features := r.Fremote.Features()
if features.ReadMetadata && !got[i].IsDir {
assert.Greater(t, len(got[i].Metadata), 0, "Expecting metadata for file")
}
if features.ReadDirMetadata && got[i].IsDir {
assert.Greater(t, len(got[i].Metadata), 0, "Expecting metadata for dir")
}
}
if test.opt.ShowHash {
hashes := got[i].Hashes
assert.NotNil(t, hashes)