Documentation
¶
Overview ¶
Package azuresql provides an in-memory mock of Microsoft.Sql (Azure SQL Database). It implements relationaldb/driver.RelationalDB so the same backend serves both the portable API (relationaldb.DB) and the SDK-compat HTTP layer.
Mapping into the relationaldb shape:
- Cluster → Microsoft.Sql logical server (a connection endpoint that groups databases, billed per-DB).
- Instance with ClusterID → A database under that server. The instance ID in the portable API is the DB name; the ClusterID is the server name.
- Snapshot → A database long-term retention backup.
- ClusterSnapshot → Not supported (Azure SQL has no server-level snapshots). Cluster-snapshot methods return InvalidArgument.
Lifecycle: Azure SQL databases are "always on" — there is no native start/stop API. The mock still tracks state transitions so portable-API users can drive Start/Stop and observe deterministic behavior; the transitions don't affect the ARM-visible state.
Index ¶
- type Mock
- func (m *Mock) CreateCluster(_ context.Context, cfg rdsdriver.ClusterConfig) (*rdsdriver.Cluster, error)
- func (*Mock) CreateClusterSnapshot(_ context.Context, _ rdsdriver.ClusterSnapshotConfig) (*rdsdriver.ClusterSnapshot, error)
- func (m *Mock) CreateInstance(_ context.Context, cfg rdsdriver.InstanceConfig) (*rdsdriver.Instance, error)
- func (m *Mock) CreateSnapshot(_ context.Context, cfg rdsdriver.SnapshotConfig) (*rdsdriver.Snapshot, error)
- func (m *Mock) DeleteCluster(_ context.Context, id string) error
- func (*Mock) DeleteClusterSnapshot(_ context.Context, _ string) error
- func (m *Mock) DeleteInstance(_ context.Context, id string) error
- func (m *Mock) DeleteSnapshot(_ context.Context, id string) error
- func (*Mock) DescribeClusterSnapshots(_ context.Context, _ []string, _ string) ([]rdsdriver.ClusterSnapshot, error)
- func (m *Mock) DescribeClusters(_ context.Context, ids []string) ([]rdsdriver.Cluster, error)
- func (m *Mock) DescribeInstances(_ context.Context, ids []string) ([]rdsdriver.Instance, error)
- func (m *Mock) DescribeSnapshots(_ context.Context, ids []string, instanceID string) ([]rdsdriver.Snapshot, error)
- func (m *Mock) ModifyCluster(_ context.Context, id string, input rdsdriver.ModifyInstanceInput) (*rdsdriver.Cluster, error)
- func (m *Mock) ModifyInstance(_ context.Context, id string, input rdsdriver.ModifyInstanceInput) (*rdsdriver.Instance, error)
- func (m *Mock) RebootInstance(_ context.Context, id string) error
- func (*Mock) RestoreClusterFromSnapshot(_ context.Context, _ rdsdriver.RestoreClusterInput) (*rdsdriver.Cluster, error)
- func (m *Mock) RestoreInstanceFromSnapshot(_ context.Context, input rdsdriver.RestoreInstanceInput) (*rdsdriver.Instance, error)
- func (m *Mock) SetMonitoring(mon mondriver.Monitoring)
- func (*Mock) StartCluster(_ context.Context, _ string) error
- func (m *Mock) StartInstance(_ context.Context, id string) error
- func (*Mock) StopCluster(_ context.Context, _ string) error
- func (m *Mock) StopInstance(_ context.Context, id string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Mock ¶
type Mock struct {
// contains filtered or unexported fields
}
Mock is the in-memory Azure SQL implementation.
func (*Mock) CreateCluster ¶
func (m *Mock) CreateCluster(_ context.Context, cfg rdsdriver.ClusterConfig) (*rdsdriver.Cluster, error)
CreateCluster creates an Azure SQL logical server.
func (*Mock) CreateClusterSnapshot ¶
func (*Mock) CreateClusterSnapshot( _ context.Context, _ rdsdriver.ClusterSnapshotConfig, ) (*rdsdriver.ClusterSnapshot, error)
CreateClusterSnapshot is unsupported on Azure SQL.
func (*Mock) CreateInstance ¶
func (m *Mock) CreateInstance(_ context.Context, cfg rdsdriver.InstanceConfig) (*rdsdriver.Instance, error)
CreateInstance creates a new database under an existing logical server.
func (*Mock) CreateSnapshot ¶
func (m *Mock) CreateSnapshot(_ context.Context, cfg rdsdriver.SnapshotConfig) (*rdsdriver.Snapshot, error)
CreateSnapshot creates a long-term retention backup of a database.
func (*Mock) DeleteCluster ¶
DeleteCluster removes a server. Real Azure cascade-deletes child databases; the mock matches that behavior so tests don't have to manually clean up.
func (*Mock) DeleteClusterSnapshot ¶
DeleteClusterSnapshot is unsupported on Azure SQL.
func (*Mock) DeleteInstance ¶
DeleteInstance removes a database.
func (*Mock) DeleteSnapshot ¶
DeleteSnapshot removes a backup.
func (*Mock) DescribeClusterSnapshots ¶
func (*Mock) DescribeClusterSnapshots( _ context.Context, _ []string, _ string, ) ([]rdsdriver.ClusterSnapshot, error)
DescribeClusterSnapshots returns an empty list — Azure SQL has none.
func (*Mock) DescribeClusters ¶
DescribeClusters returns servers (or all if ids empty).
func (*Mock) DescribeInstances ¶
DescribeInstances returns instances. With ids empty: all databases across all servers. With ids set: each id may be either bare "{database}" (resolved against the unique server, ambiguity error otherwise) or the composite "{server}/{database}".
func (*Mock) DescribeSnapshots ¶
func (m *Mock) DescribeSnapshots( _ context.Context, ids []string, instanceID string, ) ([]rdsdriver.Snapshot, error)
DescribeSnapshots returns snapshots filtered by ids and/or instance.
func (*Mock) ModifyCluster ¶
func (m *Mock) ModifyCluster( _ context.Context, id string, input rdsdriver.ModifyInstanceInput, ) (*rdsdriver.Cluster, error)
ModifyCluster updates server-level fields (admin password reset, version).
func (*Mock) ModifyInstance ¶
func (m *Mock) ModifyInstance( _ context.Context, id string, input rdsdriver.ModifyInstanceInput, ) (*rdsdriver.Instance, error)
ModifyInstance applies the supplied changes to a database.
func (*Mock) RebootInstance ¶
RebootInstance is a no-op state-wise; emits a fresh metric tick.
func (*Mock) RestoreClusterFromSnapshot ¶
func (*Mock) RestoreClusterFromSnapshot( _ context.Context, _ rdsdriver.RestoreClusterInput, ) (*rdsdriver.Cluster, error)
RestoreClusterFromSnapshot is unsupported on Azure SQL.
func (*Mock) RestoreInstanceFromSnapshot ¶
func (m *Mock) RestoreInstanceFromSnapshot( _ context.Context, input rdsdriver.RestoreInstanceInput, ) (*rdsdriver.Instance, error)
RestoreInstanceFromSnapshot creates a new database from a backup.
func (*Mock) SetMonitoring ¶
func (m *Mock) SetMonitoring(mon mondriver.Monitoring)
SetMonitoring wires an Azure-Monitor-style backend for auto-metric emission.
func (*Mock) StartCluster ¶
StartCluster / StopCluster are no-ops on Azure SQL servers. They aren't "started" / "stopped" the way RDS clusters are; the underlying databases are independently controlled.
func (*Mock) StartInstance ¶
StartInstance flips a database to available state. Azure SQL doesn't have a native start endpoint, so this is observable only via the portable API.
func (*Mock) StopCluster ¶
StopCluster is a no-op on Azure SQL servers.