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.
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.
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.
Index ¶
- func GetOrCreateClient(ctx context.Context) (*storage.Client, error)
- type BucketHandle
- type BucketHandleImpl
- func (b *BucketHandleImpl) Create(ctx context.Context, projectID string, attrs *storage.BucketAttrs) (err error)
- func (b *BucketHandleImpl) Delete(ctx context.Context) error
- func (b *BucketHandleImpl) Object(name string) ObjectHandle
- func (b *BucketHandleImpl) Update(ctx context.Context, uattrs storage.BucketAttrsToUpdate) (attrs *storage.BucketAttrs, err error)
- type BucketHandleMock
- func (b *BucketHandleMock) Create(ctx context.Context, projectID string, attrs *storage.BucketAttrs) (err error)
- func (b *BucketHandleMock) Delete(ctx context.Context) error
- func (b *BucketHandleMock) Object(name string) ObjectHandle
- func (b *BucketHandleMock) Update(ctx context.Context, uattrs storage.BucketAttrsToUpdate) (attrs *storage.BucketAttrs, err error)
- type ObjectHandle
- type ObjectHandleImpl
- type ObjectHandleMock
- type ReaderMock
- type StorageClient
- type StorageClientImpl
- type StorageClientMock
- type WriterMock
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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) 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) 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 ¶
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
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 ¶
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