mirror of
https://github.com/rclone/rclone.git
synced 2025-02-22 07:27:41 +08:00
fstests: Relax MimeType support checking #5587
Before this change we checked that features.ReadMimeTime was set if and only if the Object.MimeType method was implemented. However this test is overly general - we don't care if Objects advertise MimeType when features.ReadMimeTime is set provided that they always return an empty string (which is what a wrapping backend might do). This patch implements that logic.
This commit is contained in:
parent
cc2f6f722c
commit
8cd3251b57
@ -1333,12 +1333,14 @@ func Run(t *testing.T, opt *Opt) {
|
|||||||
features := f.Features()
|
features := f.Features()
|
||||||
obj := findObject(ctx, t, f, file1.Path)
|
obj := findObject(ctx, t, f, file1.Path)
|
||||||
do, ok := obj.(fs.MimeTyper)
|
do, ok := obj.(fs.MimeTyper)
|
||||||
require.Equal(t, features.ReadMimeType, ok, "mismatch between Object.MimeType and Features.ReadMimeType")
|
|
||||||
if !ok {
|
if !ok {
|
||||||
|
require.False(t, features.ReadMimeType, "Features.ReadMimeType is set but Object.MimeType method not found")
|
||||||
t.Skip("MimeType method not supported")
|
t.Skip("MimeType method not supported")
|
||||||
}
|
}
|
||||||
mimeType := do.MimeType(ctx)
|
mimeType := do.MimeType(ctx)
|
||||||
if features.WriteMimeType {
|
if !features.ReadMimeType {
|
||||||
|
require.Equal(t, "", mimeType, "Features.ReadMimeType is not set but Object.MimeType returned a non-empty MimeType")
|
||||||
|
} else if features.WriteMimeType {
|
||||||
assert.Equal(t, file1MimeType, mimeType, "can read and write mime types but failed")
|
assert.Equal(t, file1MimeType, mimeType, "can read and write mime types but failed")
|
||||||
} else {
|
} else {
|
||||||
if strings.ContainsRune(mimeType, ';') {
|
if strings.ContainsRune(mimeType, ';') {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user