storageclient

package
v1.0.1-0...-b7ad348 Latest Latest
Warning

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

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

Documentation

Overview

Copyright 2024 Google LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetOrCreateClient

func GetOrCreateClient(ctx context.Context) (*storage.Client, error)

Types

type BucketHandle

type BucketHandle interface {
	Create(ctx context.Context, projectID string, attrs *storage.BucketAttrs) (err error)
	Update(ctx context.Context, uattrs storage.BucketAttrsToUpdate) (attrs *storage.BucketAttrs, err error)
	Object(name string) ObjectHandle
	Delete(ctx context.Context) error
}

Use this interface instead of storage.BucketHandle to support mocking.

type BucketHandleImpl

type BucketHandleImpl struct {
	// contains filtered or unexported fields
}

This implements the BucketHandle interface. This is the primary implementation that should be used in all places other than tests.

func (*BucketHandleImpl) Create

func (b *BucketHandleImpl) Create(ctx context.Context, projectID string, attrs *storage.BucketAttrs) (err error)

func (*BucketHandleImpl) Delete

func (b *BucketHandleImpl) Delete(ctx context.Context) error

func (*BucketHandleImpl) Object

func (b *BucketHandleImpl) Object(name string) ObjectHandle

func (*BucketHandleImpl) Update

func (b *BucketHandleImpl) Update(ctx context.Context, uattrs storage.BucketAttrsToUpdate) (attrs *storage.BucketAttrs, err error)

type BucketHandleMock

type BucketHandleMock struct {
	CreateMock func(ctx context.Context, projectID string, attrs *storage.BucketAttrs) (err error)
	UpdateMock func(ctx context.Context, uattrs storage.BucketAttrsToUpdate) (attrs *storage.BucketAttrs, err error)
	ObjectMock func(name string) ObjectHandle
	DeleteMock func(ctx context.Context) error
}

Mock that implements the BucketHandle interface. Pass in unit tests where BucketHandle is an input parameter.

func (*BucketHandleMock) Create

func (b *BucketHandleMock) Create(ctx context.Context, projectID string, attrs *storage.BucketAttrs) (err error)

func (*BucketHandleMock) Delete

func (b *BucketHandleMock) Delete(ctx context.Context) error

func (*BucketHandleMock) Object

func (b *BucketHandleMock) Object(name string) ObjectHandle

func (*BucketHandleMock) Update

func (b *BucketHandleMock) Update(ctx context.Context, uattrs storage.BucketAttrsToUpdate) (attrs *storage.BucketAttrs, err error)

type ObjectHandle

type ObjectHandle interface {
	NewWriter(ctx context.Context) io.WriteCloser
	NewReader(ctx context.Context) (io.ReadCloser, error)
}

Use this interface instead of storage.ObjectHandle to support mocking.

type ObjectHandleImpl

type ObjectHandleImpl struct {
	// contains filtered or unexported fields
}

This implements the ObjectHandle interface. This is the primary implementation that should be used in all places other than tests.

func (*ObjectHandleImpl) NewReader

func (o *ObjectHandleImpl) NewReader(ctx context.Context) (io.ReadCloser, error)

func (*ObjectHandleImpl) NewWriter

func (o *ObjectHandleImpl) NewWriter(ctx context.Context) io.WriteCloser

type ObjectHandleMock

type ObjectHandleMock struct {
	NewWriterMock func(ctx context.Context) io.WriteCloser
	NewReaderMock func(ctx context.Context) (io.ReadCloser, error)
}

Mock that implements the ObjectHandle interface. Pass in unit tests where ObjectHandle is an input parameter.

func (*ObjectHandleMock) NewReader

func (o *ObjectHandleMock) NewReader(ctx context.Context) (io.ReadCloser, error)

func (*ObjectHandleMock) NewWriter

func (o *ObjectHandleMock) NewWriter(ctx context.Context) io.WriteCloser

type ReaderMock

type ReaderMock struct {
	ReadMock  func(p []byte) (n int, err error)
	CloseMock func() error
}

Mock that implements the io.ReadCloser interface. Pass in unit tests where io.ReadCloser is an input parameter.

func (*ReaderMock) Close

func (r *ReaderMock) Close() error

func (*ReaderMock) Read

func (r *ReaderMock) Read(p []byte) (n int, err error)

type StorageClient

type StorageClient interface {
	Bucket(name string) BucketHandle
}

Use this interface instead of storage.Client to support mocking.

type StorageClientImpl

type StorageClientImpl struct {
	// contains filtered or unexported fields
}

This implements the StorageClient interface. This is the primary implementation that should be used in all places other than tests.

func NewStorageClientImpl

func NewStorageClientImpl(ctx context.Context) (*StorageClientImpl, error)

func (*StorageClientImpl) Bucket

func (c *StorageClientImpl) Bucket(name string) BucketHandle

type StorageClientMock

type StorageClientMock struct {
	BucketMock func(name string) BucketHandle
}

Mock that implements the StorageClient interface. Pass in unit tests where StorageClient is an input parameter.

func (*StorageClientMock) Bucket

func (scm *StorageClientMock) Bucket(name string) BucketHandle

type WriterMock

type WriterMock struct {
	WriteMock func(p []byte) (n int, err error)
	CloseMock func() error
}

Mock that implements the io.WriteCloser interface. Pass in unit tests where io.WriteCloser is an input parameter.

func (*WriterMock) Close

func (w *WriterMock) Close() error

func (*WriterMock) Write

func (w *WriterMock) Write(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

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