gcsfake

package
v0.1.75 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package cloudtest provides utilities for testing, e.g. cloud service tests using mock http Transport, fake storage client, etc.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BucketHandle

type BucketHandle struct {
	stiface.BucketHandle
	ObjAttrs       []*storage.ObjectAttrs // Objects that will be returned by iterator
	Objs           map[string]*ObjectHandle
	WritesMustFail bool
	ClosesMustFail bool
}

BucketHandle provides a fake BucketHandle implementation for testing.

func NewBucketHandle added in v0.1.44

func NewBucketHandle() *BucketHandle

NewBucketHandle creates a new empty BucketHandle.

func (*BucketHandle) Attrs

func (bh *BucketHandle) Attrs(ctx context.Context) (*storage.BucketAttrs, error)

Attrs implements trivial stiface.BucketHandle.Attrs

func (*BucketHandle) Object added in v0.1.44

func (bh *BucketHandle) Object(name string) stiface.ObjectHandle

Object returns an ObjectHandle for the specified object name if it exists in this bucket, or a new ObjectHandle otherwise.

func (*BucketHandle) Objects

Objects implements stiface.BucketHandle.Objects

type GCSClient

type GCSClient struct {
	stiface.Client
	// contains filtered or unexported fields
}

GCSClient provides a fake storage client that can be customized with arbitrary fake bucket contents.

func (*GCSClient) AddTestBucket

func (c *GCSClient) AddTestBucket(name string, bh *BucketHandle)

AddTestBucket adds a fake bucket for testing.

func (*GCSClient) Bucket

func (c *GCSClient) Bucket(name string) stiface.BucketHandle

Bucket implements stiface.Client.Bucket

func (*GCSClient) Close

func (c *GCSClient) Close() error

Close implements stiface.Client.Close

type ObjectHandle added in v0.1.44

type ObjectHandle struct {
	stiface.ObjectHandle
	Name           string
	Bucket         *BucketHandle
	Data           *bytes.Buffer
	WritesMustFail bool
	ClosesMustFail bool
}

ObjectHandle implements stiface.ObjectHandle

func (*ObjectHandle) NewReader added in v0.1.44

func (o *ObjectHandle) NewReader(context.Context) (stiface.Reader, error)

NewReader returns a fakeReader for this ObjectHandle.

func (*ObjectHandle) NewWriter added in v0.1.44

func (o *ObjectHandle) NewWriter(context.Context) stiface.Writer

NewWriter returns a fakeWrite for this ObjectHandle.

Jump to

Keyboard shortcuts

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