mirror of
https://github.com/rclone/rclone
synced 2025-01-12 15:46:25 +01:00
fstest: use WithMetadata / WithMimeType
This commit is contained in:
parent
458845ce89
commit
ec2024b907
@ -152,38 +152,6 @@ func retry(t *testing.T, what string, f func() error) {
|
||||
require.NoError(t, err, what)
|
||||
}
|
||||
|
||||
// An fs.ObjectInfo that can override mime type
|
||||
type objectInfoWithMimeType struct {
|
||||
fs.ObjectInfo
|
||||
mimeType string
|
||||
metadata fs.Metadata
|
||||
}
|
||||
|
||||
// Return a wrapped fs.ObjectInfo which returns the mime type given
|
||||
func overrideMimeType(o fs.ObjectInfo, mimeType string, metadata fs.Metadata) fs.ObjectInfo {
|
||||
return &objectInfoWithMimeType{
|
||||
ObjectInfo: o,
|
||||
mimeType: mimeType,
|
||||
metadata: metadata,
|
||||
}
|
||||
}
|
||||
|
||||
// MimeType that was overridden
|
||||
func (o *objectInfoWithMimeType) MimeType(ctx context.Context) string {
|
||||
return o.mimeType
|
||||
}
|
||||
|
||||
// Metadata that was overridden
|
||||
func (o *objectInfoWithMimeType) Metadata(ctx context.Context) (fs.Metadata, error) {
|
||||
return o.metadata, nil
|
||||
}
|
||||
|
||||
// check interfaces
|
||||
var (
|
||||
_ fs.MimeTyper = (*objectInfoWithMimeType)(nil)
|
||||
_ fs.Metadataer = (*objectInfoWithMimeType)(nil)
|
||||
)
|
||||
|
||||
// check interface
|
||||
|
||||
// PutTestContentsMetadata puts file with given contents to the remote and checks it but unlike TestPutLarge doesn't remove
|
||||
@ -214,7 +182,7 @@ func PutTestContentsMetadata(ctx context.Context, t *testing.T, f fs.Fs, file *f
|
||||
ci.Metadata = previousMetadata
|
||||
}()
|
||||
}
|
||||
obji = overrideMimeType(obji, mimeType, metadata)
|
||||
obji.WithMetadata(metadata).WithMimeType(mimeType)
|
||||
}
|
||||
obj, err = f.Put(ctx, in, obji)
|
||||
return err
|
||||
|
Loading…
Reference in New Issue
Block a user