Documentation ¶
Overview ¶
Package mock provides fake object storage endpoints for testing
The structs defined here all implement the github.com/ibmjstart/swiftlygo/auth.Destination interface and are therefore useful for testing any code that uploads data via a destination. It includes an endpoint that does nothing, an endpoint that stores uploaded data in memory, and an endpoint that always generates errors.
Index ¶
- type BufferDestination
- func (b *BufferDestination) CreateDLO(containerName, manifestName, objectContainer, filenamePrefix string) error
- func (b *BufferDestination) CreateFile(container, objectName string, checkHash bool, Hash string) (auth.WriteCloseHeader, error)
- func (b *BufferDestination) CreateSLO(containerName, manifestName, manifestEtag string, sloManifestJSON []byte) error
- func (b *BufferDestination) FileNames(container string) ([]string, error)
- func (b *BufferDestination) Objects(container string) ([]swift.Object, error)
- type ErrorDestination
- func (e ErrorDestination) CreateDLO(containerName, manifestName, objectContainer, filenamePrefix string) error
- func (e ErrorDestination) CreateFile(container, objectName string, checkHash bool, Hash string) (auth.WriteCloseHeader, error)
- func (e ErrorDestination) CreateSLO(containerName, manifestName, manifestEtag string, sloManifestJSON []byte) error
- func (e ErrorDestination) FileNames(container string) ([]string, error)
- func (e ErrorDestination) Objects(container string) ([]swift.Object, error)
- type NullDestination
- func (n NullDestination) CreateDLO(containerName, manifestName, objectContainer, filenamePrefix string) error
- func (n NullDestination) CreateFile(container, objectName string, checkHash bool, Hash string) (auth.WriteCloseHeader, error)
- func (n NullDestination) CreateSLO(containerName, manifestName, manifestEtag string, sloManifestJSON []byte) error
- func (n NullDestination) FileNames(container string) ([]string, error)
- func (n NullDestination) Objects(container string) ([]swift.Object, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BufferDestination ¶
type BufferDestination struct { Containers map[string][]string FileContent *closableBuffer ManifestContent *bytes.Buffer }
BufferDestination implements the Destination and keeps the observed container names, object names, file data, and manifest data for later retrieval and testing.
func NewBufferDestination ¶
func NewBufferDestination() *BufferDestination
NewBufferDestination creates a new instance of BufferDestination
func (*BufferDestination) CreateDLO ¶
func (b *BufferDestination) CreateDLO(containerName, manifestName, objectContainer, filenamePrefix string) error
CreateDLO always returns nil.
func (*BufferDestination) CreateFile ¶
func (b *BufferDestination) CreateFile(container, objectName string, checkHash bool, Hash string) (auth.WriteCloseHeader, error)
CreateFile returns a reference to the fileContent buffer held by this BufferDestination that can be written into, though it may not be safe for concurrent operations.
func (*BufferDestination) CreateSLO ¶
func (b *BufferDestination) CreateSLO(containerName, manifestName, manifestEtag string, sloManifestJSON []byte) error
CreateSLO always returns nil.
type ErrorDestination ¶
type ErrorDestination struct{}
ErrorDestination implements the Destination interface but always returns the error values of its methods.
func NewErrorDestination ¶
func NewErrorDestination() ErrorDestination
NewErrorDestination creates a destination that always errors out.
func (ErrorDestination) CreateDLO ¶
func (e ErrorDestination) CreateDLO(containerName, manifestName, objectContainer, filenamePrefix string) error
CreateDLO always returns an empty error.
func (ErrorDestination) CreateFile ¶
func (e ErrorDestination) CreateFile(container, objectName string, checkHash bool, Hash string) (auth.WriteCloseHeader, error)
CreateFile always returns an io.WriteCloser that does nothing and an empty error.
func (ErrorDestination) CreateSLO ¶
func (e ErrorDestination) CreateSLO(containerName, manifestName, manifestEtag string, sloManifestJSON []byte) error
CreateSLO always returns an empty error.
type NullDestination ¶
type NullDestination struct{}
NullDestination implements the Destination interface but always returns the zero values of its methods.
func NewNullDestination ¶
func NewNullDestination() NullDestination
NewNullDestination creates a new mock destination that makes no attempt to store the data written to it but does not return errors.
func (NullDestination) CreateDLO ¶
func (n NullDestination) CreateDLO(containerName, manifestName, objectContainer, filenamePrefix string) error
CreateDLO always returns nil.
func (NullDestination) CreateFile ¶
func (n NullDestination) CreateFile(container, objectName string, checkHash bool, Hash string) (auth.WriteCloseHeader, error)
CreateFile takes the provided information and consigns it to the void. It returns an io.WriteCloser that will ignore all data written.
func (NullDestination) CreateSLO ¶
func (n NullDestination) CreateSLO(containerName, manifestName, manifestEtag string, sloManifestJSON []byte) error
CreateSLO always returns nil.