luci: go.chromium.org/luci/cipd/appengine/impl/testutil Index | Files

package testutil

import "go.chromium.org/luci/cipd/appengine/impl/testutil"

Package testutil contains helpers used from CIPD backend unit tests.

Index

Package Files

cas.go doc.go gs.go metadata.go zip.go

func MakeZip Uses

func MakeZip(files map[string]string) []byte

MakeZip produces a zip archive with given files.

Can be used to test reading of CIPD packages.

type MetadataStore Uses

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

MetadataStore implements metadata.Storage using memory, for tests.

Not terribly efficient, shouldn't be used with a large number of entries.

func (*MetadataStore) GetMetadata Uses

func (s *MetadataStore) GetMetadata(c context.Context, prefix string) ([]*api.PrefixMetadata, error)

GetMetadata fetches metadata associated with the given prefix and all parent prefixes.

func (*MetadataStore) Populate Uses

func (s *MetadataStore) Populate(prefix string, m *api.PrefixMetadata) *api.PrefixMetadata

Populate adds a metadata entry to the storage.

If populates Prefix and Fingerprint. Returns the added item. Panics if the prefix is bad or the given metadata is empty.

func (*MetadataStore) Purge Uses

func (s *MetadataStore) Purge(prefix string)

Purge removes metadata entry for some prefix.

Panics if the prefix is bad. Purging missing metadata is noop.

func (*MetadataStore) UpdateMetadata Uses

func (s *MetadataStore) UpdateMetadata(c context.Context, prefix string, cb func(m *api.PrefixMetadata) error) (*api.PrefixMetadata, error)

UpdateMetadata transactionally updates or creates metadata of some prefix.

func (*MetadataStore) VisitMetadata Uses

func (s *MetadataStore) VisitMetadata(c context.Context, prefix string, cb metadata.Visitor) error

VisitMetadata performs depth-first enumeration of the metadata graph.

type MockCAS Uses

type MockCAS struct {
    Err error // an error to return or nil to pass through to the callback

    GetReaderImpl    func(context.Context, *api.ObjectRef) (gs.Reader, error)
    GetObjectURLImpl func(context.Context, *api.GetObjectURLRequest) (*api.ObjectURL, error)
    BeginUploadImpl  func(context.Context, *api.BeginUploadRequest) (*api.UploadOperation, error)
    FinishUploadImpl func(context.Context, *api.FinishUploadRequest) (*api.UploadOperation, error)
    CancelUploadImpl func(context.Context, *api.CancelUploadRequest) (*api.UploadOperation, error)
}

MockCAS implements cas.StorageServer interface.

func (*MockCAS) BeginUpload Uses

func (m *MockCAS) BeginUpload(c context.Context, r *api.BeginUploadRequest) (*api.UploadOperation, error)

BeginUpload implements the corresponding RPC method, see the proto doc.

func (*MockCAS) CancelUpload Uses

func (m *MockCAS) CancelUpload(c context.Context, r *api.CancelUploadRequest) (*api.UploadOperation, error)

CancelUpload implements the corresponding RPC method, see the proto doc.

func (*MockCAS) FinishUpload Uses

func (m *MockCAS) FinishUpload(c context.Context, r *api.FinishUploadRequest) (*api.UploadOperation, error)

FinishUpload implements the corresponding RPC method, see the proto doc.

func (*MockCAS) GetObjectURL Uses

func (m *MockCAS) GetObjectURL(c context.Context, r *api.GetObjectURLRequest) (*api.ObjectURL, error)

GetObjectURL implements the corresponding RPC method, see the proto doc.

func (*MockCAS) GetReader Uses

func (m *MockCAS) GetReader(c context.Context, ref *api.ObjectRef) (gs.Reader, error)

GetReader implements the corresponding method of cas.StorageServer interface.

type MockGSReader Uses

type MockGSReader struct {
    io.ReaderAt

    Len int64
    Gen int64
}

MockGSReader implements gs.Reader on top of a regular io.ReaderAt.

func NewMockGSReader Uses

func NewMockGSReader(data []byte) *MockGSReader

NewMockGSReader constructs MockGSReader from a byte slice.

func (*MockGSReader) Generation Uses

func (m *MockGSReader) Generation() int64

Generation is part of gs.Reader interface.

func (*MockGSReader) Size Uses

func (m *MockGSReader) Size() int64

Size is part of gs.Reader interface.

type NoopGoogleStorage Uses

type NoopGoogleStorage struct {
    Err error // an error to return or nil to panic
}

NoopGoogleStorage implements gs.GoogleStorage interface by returning errors.

Can be embedded into mock implementations that override some subset of methods.

func (NoopGoogleStorage) CancelUpload Uses

func (n NoopGoogleStorage) CancelUpload(c context.Context, uploadURL string) error

CancelUpload is part of gs.GoogleStorage interface.

func (NoopGoogleStorage) Copy Uses

func (n NoopGoogleStorage) Copy(c context.Context, dst string, dstGen int64, src string, srcGen int64) error

Copy is part of gs.GoogleStorage interface.

func (NoopGoogleStorage) Delete Uses

func (n NoopGoogleStorage) Delete(c context.Context, path string) error

Delete is part of gs.GoogleStorage interface.

func (NoopGoogleStorage) Exists Uses

func (n NoopGoogleStorage) Exists(c context.Context, path string) (exists bool, err error)

Exists is part of gs.GoogleStorage interface.

func (NoopGoogleStorage) Publish Uses

func (n NoopGoogleStorage) Publish(c context.Context, dst, src string, srcGen int64) error

Publish is part of gs.GoogleStorage interface.

func (NoopGoogleStorage) Reader Uses

func (n NoopGoogleStorage) Reader(c context.Context, path string, gen int64) (gs.Reader, error)

Reader is part of gs.GoogleStorage interface.

func (NoopGoogleStorage) StartUpload Uses

func (n NoopGoogleStorage) StartUpload(c context.Context, path string) (uploadURL string, err error)

StartUpload is part of gs.GoogleStorage interface.

Package testutil imports 12 packages (graph). Updated 2018-08-20. Refresh now. Tools for package owners.