Documentation ¶
Overview ¶
Package mockobject provides a mock object which can be created from a string
Index ¶
- Variables
- type ContentMockObject
- func (o *ContentMockObject) Fs() fs.Info
- func (o *ContentMockObject) Hash(ctx context.Context, t hash.Type) (string, error)
- func (o *ContentMockObject) ModTime(ctx context.Context) time.Time
- func (o *ContentMockObject) Open(ctx context.Context, options ...fs.OpenOption) (io.ReadCloser, error)
- func (o *ContentMockObject) SetFs(f fs.Fs)
- func (o *ContentMockObject) SetModTime(ctx context.Context, t time.Time) error
- func (o *ContentMockObject) SetUnknownSize(unknownSize bool)
- func (o *ContentMockObject) Size() int64
- type Object
- func (o Object) Fs() fs.Info
- func (o Object) Hash(ctx context.Context, t hash.Type) (string, error)
- func (o Object) ModTime(ctx context.Context) (t time.Time)
- func (o Object) Open(ctx context.Context, options ...fs.OpenOption) (io.ReadCloser, error)
- func (o Object) Remote() string
- func (o Object) Remove(ctx context.Context) error
- func (o Object) SetModTime(ctx context.Context, t time.Time) error
- func (o Object) Size() int64
- func (o Object) Storable() bool
- func (o Object) String() string
- func (o Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, options ...fs.OpenOption) error
- func (o Object) WithContent(content []byte, mode SeekMode) *ContentMockObject
- type SeekMode
Constants ¶
This section is empty.
Variables ¶
var SeekModes = []SeekMode{SeekModeNone, SeekModeRegular, SeekModeRange}
SeekModes contains all valid SeekMode's
Functions ¶
This section is empty.
Types ¶
type ContentMockObject ¶ added in v1.6.1
type ContentMockObject struct { Object // contains filtered or unexported fields }
ContentMockObject mocks an fs.Object and has content, mod time
func (*ContentMockObject) Fs ¶ added in v1.6.1
func (o *ContentMockObject) Fs() fs.Info
Fs returns read only access to the Fs that this object is part of
This is nil unless SetFs has been called
func (*ContentMockObject) Hash ¶ added in v1.50.20
Hash returns the selected checksum of the file If no checksum is available it returns ""
func (*ContentMockObject) ModTime ¶ added in v1.62.1
func (o *ContentMockObject) ModTime(ctx context.Context) time.Time
ModTime returns the modification date of the file It should return a best guess if one isn't available
func (*ContentMockObject) Open ¶ added in v1.6.1
func (o *ContentMockObject) Open(ctx context.Context, options ...fs.OpenOption) (io.ReadCloser, error)
Open opens the file for read. Call Close() on the returned io.ReadCloser
func (*ContentMockObject) SetFs ¶ added in v1.6.1
func (o *ContentMockObject) SetFs(f fs.Fs)
SetFs sets the return value of the Fs() call
func (*ContentMockObject) SetModTime ¶ added in v1.62.1
SetModTime sets the metadata on the object to set the modification date
func (*ContentMockObject) SetUnknownSize ¶ added in v1.6.1
func (o *ContentMockObject) SetUnknownSize(unknownSize bool)
SetUnknownSize makes the mock object return -1 for size if true
func (*ContentMockObject) Size ¶ added in v1.6.1
func (o *ContentMockObject) Size() int64
Size returns the size of the file
type Object ¶
type Object string
Object is a mock fs.Object useful for testing
func (Object) Hash ¶
Hash returns the selected checksum of the file If no checksum is available it returns ""
func (Object) ModTime ¶
ModTime returns the modification date of the file It should return a best guess if one isn't available
func (Object) Open ¶
func (o Object) Open(ctx context.Context, options ...fs.OpenOption) (io.ReadCloser, error)
Open opens the file for read. Call Close() on the returned io.ReadCloser
func (Object) SetModTime ¶
SetModTime sets the metadata on the object to set the modification date
func (Object) Update ¶
func (o Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, options ...fs.OpenOption) error
Update in to the object with the modTime given of the given size
func (Object) WithContent ¶
func (o Object) WithContent(content []byte, mode SeekMode) *ContentMockObject
WithContent returns an fs.Object with the given content.