fake

package
v0.0.72 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Lister
	Opener
}

A Client can list files and open them for reading.

type ConditionalClient

type ConditionalClient struct {
	UploadClient
	// contains filtered or unexported fields
}

ConditionalClient is a fake conditional client that can limit actions to matching conditions.

func (ConditionalClient) Copy

func (cc ConditionalClient) Copy(ctx context.Context, from, to gcs.Path) error

Copy copies the contents of 'from' into 'to'.

func (ConditionalClient) If

If returns a fake conditional client.

func (ConditionalClient) Upload

func (cc ConditionalClient) Upload(ctx context.Context, path gcs.Path, buf []byte, worldRead bool, cache string) error

Upload writes content to the given path.

type Iterator

type Iterator struct {
	Objects []storage.ObjectAttrs
	Idx     int
	Err     int // must be > 0

	Offset string
	// contains filtered or unexported fields
}

An Iterator returns the attributes of the listed objects or an iterator.Done error.

func (*Iterator) Next

func (fi *Iterator) Next() (*storage.ObjectAttrs, error)

Next returns the next value.

type Lister

type Lister map[gcs.Path]Iterator

A Lister returns objects under a prefix.

func (Lister) Objects

func (fl Lister) Objects(ctx context.Context, path gcs.Path, _, offset string) gcs.Iterator

Objects returns an iterator of objects under a given path.

type Object

type Object struct {
	Data     string
	OpenErr  error
	ReadErr  error
	CloseErr error
}

Object holds data for an object.

type Opener

type Opener map[gcs.Path]Object

Opener opens given paths.

func (Opener) Open

func (fo Opener) Open(ctx context.Context, path gcs.Path) (io.ReadCloser, error)

Open returns a handle for a given path.

type Reader

type Reader struct {
	Buf      *bytes.Buffer
	ReadErr  error
	CloseErr error
}

A Reader reads a file.

func (*Reader) Close

func (fr *Reader) Close() error

Close closes a file.

func (*Reader) Read

func (fr *Reader) Read(p []byte) (int, error)

Read reads a file's contents.

type Stat

type Stat struct {
	Err   error
	Attrs storage.ObjectAttrs
}

Stat contains object attributes for a given path.

type Stater

type Stater map[gcs.Path]Stat

Stater stats given paths.

func (Stater) Stat

func (fs Stater) Stat(ctx context.Context, path gcs.Path) (*storage.ObjectAttrs, error)

Stat returns object attributes for a given path.

type Upload

type Upload struct {
	Buf          []byte
	CacheControl string
	WorldRead    bool
	Err          error
	Generation   int64
}

Upload represents an upload.

type UploadClient

type UploadClient struct {
	Client
	Uploader
	Stater
}

UploadClient is a fake upload client

func (UploadClient) If

func (fuc UploadClient) If(read, write *storage.Conditions) gcs.ConditionalClient

If returns a fake upload client.

type Uploader

type Uploader map[gcs.Path]Upload

Uploader adds upload capabilities to a fake client.

func (Uploader) Copy

func (fu Uploader) Copy(ctx context.Context, from, to gcs.Path) error

Copy an object to the specified path

func (Uploader) Upload

func (fu Uploader) Upload(ctx context.Context, path gcs.Path, buf []byte, worldRead bool, cacheControl string) error

Upload writes content to the given path.

Jump to

Keyboard shortcuts

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