mock

package
v0.0.0-...-ee1b036 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 16, 2016 License: Apache-2.0 Imports: 6 Imported by: 0

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

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.

func (*BufferDestination) FileNames

func (b *BufferDestination) FileNames(container string) ([]string, error)

FileNames returns an empty string slice and nil.

func (*BufferDestination) Objects

func (b *BufferDestination) Objects(container string) ([]swift.Object, error)

Objects returns a slice of swift Objects corresponding to the objects within the given container. The objects only have their "Name" attribute set.

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.

func (ErrorDestination) FileNames

func (e ErrorDestination) FileNames(container string) ([]string, error)

FileNames returns an empty string slice and an empty error.

func (ErrorDestination) Objects

func (e ErrorDestination) Objects(container string) ([]swift.Object, error)

Objects returns a nil slice of swift objects and 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.

func (NullDestination) FileNames

func (n NullDestination) FileNames(container string) ([]string, error)

FileNames returns an empty string slice and nil.

func (NullDestination) Objects

func (n NullDestination) Objects(container string) ([]swift.Object, error)

Objects returns an empty slice of swift.Object and a nil error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL