databasetesting

package
v0.0.0-...-aba08df Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewPreconditionFailedError

func NewPreconditionFailedError() *azcore.ResponseError

Types

type MockDBClient

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

MockDBClient implements the database.DBClient interface for unit testing. It stores documents in memory and supports loading from cosmos-record context directories.

func NewMockDBClient

func NewMockDBClient() *MockDBClient

NewMockDBClient creates a new mock DBClient with empty storage.

func (*MockDBClient) Clear

func (m *MockDBClient) Clear()

Clear removes all documents from the mock database.

func (*MockDBClient) CreateBillingDoc

func (m *MockDBClient) CreateBillingDoc(ctx context.Context, doc *database.BillingDocument) error

CreateBillingDoc creates a new billing document.

func (*MockDBClient) DeleteDocument

func (m *MockDBClient) DeleteDocument(cosmosID string)

DeleteDocument removes a document from the mock database.

func (*MockDBClient) GetAllDocuments

func (m *MockDBClient) GetAllDocuments() map[string]json.RawMessage

GetAllDocuments returns a copy of all documents (for testing purposes).

func (*MockDBClient) GetDocument

func (m *MockDBClient) GetDocument(cosmosID string) (json.RawMessage, bool)

GetDocument retrieves a raw JSON document from the mock database.

func (*MockDBClient) GetLockClient

func (m *MockDBClient) GetLockClient() database.LockClientInterface

GetLockClient returns the mock lock client, or nil if not set.

func (*MockDBClient) GlobalListers

func (m *MockDBClient) GlobalListers() database.GlobalListers

GlobalListers returns interfaces for listing all resources of a particular type across all partitions.

func (*MockDBClient) HCPClusters

func (m *MockDBClient) HCPClusters(subscriptionID, resourceGroupName string) database.HCPClusterCRUD

HCPClusters returns a CRUD interface for HCPCluster resources.

func (*MockDBClient) ListAllDocuments

func (m *MockDBClient) ListAllDocuments(ctx context.Context) ([]*database.TypedDocument, error)

ListAllDocuments returns all documents in the mock database. This implements the DocumentLister interface from integrationutils.

func (*MockDBClient) ListDocuments

func (m *MockDBClient) ListDocuments(resourceType *azcorearm.ResourceType, prefix string) []json.RawMessage

ListDocuments returns all documents matching the given resource type and prefix.

func (*MockDBClient) LoadContent

func (m *MockDBClient) LoadContent(ctx context.Context, content []byte) error

LoadContent loads a single JSON document into the mock database. This implements the ContentLoader interface from integrationutils.

func (*MockDBClient) LoadFromDirectory

func (m *MockDBClient) LoadFromDirectory(dirPath string) error

LoadFromDirectory loads cosmos-record context data from a directory. It reads all JSON files that match the pattern for "load" directories.

func (*MockDBClient) NewTransaction

func (m *MockDBClient) NewTransaction(pk string) database.DBTransaction

NewTransaction creates a new mock transaction.

func (*MockDBClient) Operations

func (m *MockDBClient) Operations(subscriptionID string) database.OperationCRUD

Operations returns a CRUD interface for operation resources.

func (*MockDBClient) PatchBillingDoc

PatchBillingDoc patches a billing document.

func (*MockDBClient) ServiceProviderClusters

func (m *MockDBClient) ServiceProviderClusters(subscriptionID, resourceGroupName, clusterName string) database.ServiceProviderClusterCRUD

ServiceProviderClusters returns a CRUD interface for service provider cluster resources.

func (*MockDBClient) ServiceProviderNodePools

func (m *MockDBClient) ServiceProviderNodePools(subscriptionID, resourceGroupName, clusterName, nodePoolName string) database.ServiceProviderNodePoolCRUD

ServiceProviderNodePools returns a CRUD interface for service provider node pool resources.

func (*MockDBClient) SetLockClient

func (m *MockDBClient) SetLockClient(lockClient database.LockClientInterface)

SetLockClient sets a mock lock client for testing.

func (*MockDBClient) StoreDocument

func (m *MockDBClient) StoreDocument(cosmosID string, data json.RawMessage)

StoreDocument stores a raw JSON document in the mock database.

func (*MockDBClient) Subscriptions

func (m *MockDBClient) Subscriptions() database.SubscriptionCRUD

Subscriptions returns a CRUD interface for subscription resources.

func (*MockDBClient) UntypedCRUD

func (m *MockDBClient) UntypedCRUD(parentResourceID azcorearm.ResourceID) (database.UntypedResourceCRUD, error)

UntypedCRUD provides access to untyped resource operations.

type MockLockClient

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

MockLockClient implements database.LockClientInterface for testing.

func NewMockLockClient

func NewMockLockClient(defaultTTL time.Duration) *MockLockClient

NewMockLockClient creates a new mock lock client.

func (*MockLockClient) AcquireLock

func (c *MockLockClient) AcquireLock(ctx context.Context, id string, timeout *time.Duration) (*azcosmos.ItemResponse, error)

func (*MockLockClient) GetDefaultTimeToLive

func (c *MockLockClient) GetDefaultTimeToLive() time.Duration

func (*MockLockClient) HoldLock

func (*MockLockClient) ReleaseLock

func (c *MockLockClient) ReleaseLock(ctx context.Context, item *azcosmos.ItemResponse) error

func (*MockLockClient) RenewLock

func (*MockLockClient) SetRetryAfterHeader

func (c *MockLockClient) SetRetryAfterHeader(header http.Header)

func (*MockLockClient) TryAcquireLock

func (c *MockLockClient) TryAcquireLock(ctx context.Context, id string) (*azcosmos.ItemResponse, error)

Jump to

Keyboard shortcuts

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