Documentation
¶
Overview ¶
Package testutils provides utilities for testing.
Index ¶
- func MustNewDatastoreClientForTesting(t *testing.T) *datastore.Client
- func StartDatastoreEmulator(t *testing.T)
- type MockPublishResult
- type MockPublisher
- type MockStorage
- func (c *MockStorage) Close() error
- func (c *MockStorage) Objects(_ context.Context, prefix string) iter.Seq2[string, error]
- func (c *MockStorage) ReadObject(_ context.Context, path string) ([]byte, error)
- func (c *MockStorage) ReadObjectAttrs(_ context.Context, path string) (*clients.Attrs, error)
- func (c *MockStorage) WriteObject(_ context.Context, path string, data []byte, opts *clients.WriteOptions) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MustNewDatastoreClientForTesting ¶
MustNewDatastoreClientForTesting creates a new Datastore client connected to the emulator. It ensures the emulator is started and cleaned up.
func StartDatastoreEmulator ¶
StartDatastoreEmulator ensures the Datastore emulator is running once per test execution.
Types ¶
type MockPublishResult ¶
type MockPublishResult struct {
// contains filtered or unexported fields
}
type MockPublisher ¶
func (*MockPublisher) Publish ¶
func (p *MockPublisher) Publish(_ context.Context, msg *pubsub.Message) clients.PublishResult
type MockStorage ¶
type MockStorage struct {
WriteError error // Global error to return on WriteObject
WriteErrors map[string]error // Per-path error to return on WriteObject
// contains filtered or unexported fields
}
MockStorage implements osv.CloudStorage for testing.
func NewMockStorage ¶
func NewMockStorage() *MockStorage
NewMockStorage creates a new mock storage client.
func (*MockStorage) Close ¶
func (c *MockStorage) Close() error
func (*MockStorage) ReadObject ¶
func (*MockStorage) ReadObjectAttrs ¶
func (*MockStorage) WriteObject ¶
func (c *MockStorage) WriteObject(_ context.Context, path string, data []byte, opts *clients.WriteOptions) error
Click to show internal directories.
Click to hide internal directories.