azuresql

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: May 25, 2026 License: MIT Imports: 9 Imported by: 0

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

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 New

func New(opts *config.Options) *Mock

New creates a new Azure SQL mock.

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

func (m *Mock) DeleteCluster(_ context.Context, id string) error

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

func (*Mock) DeleteClusterSnapshot(_ context.Context, _ string) error

DeleteClusterSnapshot is unsupported on Azure SQL.

func (*Mock) DeleteInstance

func (m *Mock) DeleteInstance(_ context.Context, id string) error

DeleteInstance removes a database.

func (*Mock) DeleteSnapshot

func (m *Mock) DeleteSnapshot(_ context.Context, id string) error

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

func (m *Mock) DescribeClusters(_ context.Context, ids []string) ([]rdsdriver.Cluster, error)

DescribeClusters returns servers (or all if ids empty).

func (*Mock) DescribeInstances

func (m *Mock) DescribeInstances(_ context.Context, ids []string) ([]rdsdriver.Instance, error)

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

func (m *Mock) RebootInstance(_ context.Context, id string) error

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

func (*Mock) StartCluster(_ context.Context, _ string) error

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

func (m *Mock) StartInstance(_ context.Context, id string) error

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

func (*Mock) StopCluster(_ context.Context, _ string) error

StopCluster is a no-op on Azure SQL servers.

func (*Mock) StopInstance

func (m *Mock) StopInstance(_ context.Context, id string) error

StopInstance flips a database to stopped state.

Jump to

Keyboard shortcuts

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