databasemutationhelpers

package
v0.0.0-...-f20ac65 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultTestAPIVersion = "2024-06-10-preview"

DefaultTestAPIVersion is the API version used by existing integration tests. When a new API version becomes the default, update this constant and fix any test fixture response differences.

Variables

This section is empty.

Functions

func NewCosmosCRUD

func NewCosmosCRUD[InternalAPIType any, InternalAPITypePointer arm.CosmosMetadataAccessorPtr[InternalAPIType]](t *testing.T, cosmosClient database.ResourcesDBClient, parentResourceID *azcorearm.ResourceID, resourceType azcorearm.ResourceType) database.ResourceCRUD[InternalAPIType, InternalAPITypePointer]

func NewCosmosCompareStep

func NewCosmosCompareStep(stepID StepID, stepDir fs.FS) (*cosmosCompare, error)

func NewFrontendHTTPTestAccessor

func NewFrontendHTTPTestAccessor(frontEndURL string, frontendClient *hcpsdk20240610preview.ClientFactory) *frontendHTTPTestAccessor

func NewKubernetesApplyStep

func NewKubernetesApplyStep(stepID StepID, stepDir fs.FS) (*kubernetesApplyStep, error)

func NewKubernetesCompareStep

func NewKubernetesCompareStep(stepID StepID, stepDir fs.FS) (*kubernetesCompareStep, error)

func NewKubernetesLoadStep

func NewKubernetesLoadStep(stepID StepID, stepDir fs.FS) (*kubernetesLoadStep, error)

func NewLoadClusterServiceStep

func NewLoadClusterServiceStep(stepID StepID, clusterServiceContent fs.FS) (*loadClusterServiceStep, error)

func NewLoadCosmosStep

func NewLoadCosmosStep(stepID StepID, stepDir fs.FS) (*loadCosmosStep, error)

func NewVersionedHTTPTestAccessor

func NewVersionedHTTPTestAccessor(url, apiVersion string) *httpHTTPTestAccessor

NewVersionedHTTPTestAccessor creates an HTTP test accessor that sends requests with the given api-version query parameter and the required ARM headers.

func ResourceInstanceEquals

func ResourceInstanceEquals(t *testing.T, expected, actual any) (string, bool)

func ResourceName

func ResourceName(resource any) string

Types

type CosmosCRUDKey

type CosmosCRUDKey struct {
	ParentResourceID *azcorearm.ResourceID `json:"parentResourceId"`
	ResourceType     ResourceType          `json:"resourceType"`
}

type CosmosItemKey

type CosmosItemKey struct {
	ResourceID *azcorearm.ResourceID `json:"resourceId"`
}

type GetByIDCRUDKey

type GetByIDCRUDKey struct {
	CosmosCRUDKey `json:",inline"`

	CosmosID string `json:"cosmosID"`
}

type HTTPTestAccessor

type HTTPTestAccessor interface {
	Get(ctx context.Context, resourceIDString string) (any, error)
	List(ctx context.Context, parentResourceIDString string) ([]any, error)
	CreateOrUpdate(ctx context.Context, resourceIDString string, content []byte) error
	Post(ctx context.Context, resourceIDString string, content []byte) error
	Patch(ctx context.Context, resourceIDString string, content []byte) error
	Delete(ctx context.Context, resourceIDString string) error
}

type IntegrationTestStep

type IntegrationTestStep interface {
	StepID() StepID
	RunTest(ctx context.Context, t *testing.T, stepInput StepInput)
}

func NewStep

func NewStep[InternalAPIType any, InternalAPITypePointer arm.CosmosMetadataAccessorPtr[InternalAPIType]](indexString, stepType, stepName string, testDir fs.FS, path string) (IntegrationTestStep, error)

func NewUntypedStep

func NewUntypedStep(indexString, stepType, stepName string, testDir fs.FS, path string) (IntegrationTestStep, error)

NewUntypedStep dispatches step types that don't require a typed CRUD client. Returns an error for any step kind that needs an InternalAPIType (create, replace, get, getByID, list, delete, replaceWithETag) — those must go through NewStep.

type OperationAccessor

type OperationAccessor interface {
	CompleteOperation(ctx context.Context, resourceIDString string) error
}

type ResourceKey

type ResourceKey struct {
	ResourceID string `json:"resourceId"`

	// APIVersion specifies the ARM api-version query parameter for HTTP operations.
	// Valid values are ARM API version strings (e.g., "2024-06-10-preview", "2025-12-23-preview").
	// If empty, falls back to StepInput.APIVersion, then DefaultTestAPIVersion.
	// Only used by HTTP step types; non-HTTP steps (e.g., completeOperation) ignore this field.
	APIVersion string `json:"apiVersion,omitempty"`
}

ResourceKey identifies an ARM resource for test step operations. Used by HTTP step types (httpCreate, httpGet, httpPost, httpPatch, httpDelete, httpList) and by completeOperation (which uses only ResourceID).

type ResourceMutationTest

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

func NewResourceMutationTest

func NewResourceMutationTest[InternalAPIType any, InternalAPITypePointer arm.CosmosMetadataAccessorPtr[InternalAPIType]](ctx context.Context, testName string, testDir fs.FS, withMock bool) (*ResourceMutationTest, error)

func NewUntypedResourceMutationTest

func NewUntypedResourceMutationTest(ctx context.Context, testName string, testDir fs.FS, withMock bool) (*ResourceMutationTest, error)

NewUntypedResourceMutationTest builds a ResourceMutationTest whose step dispatch only knows about untyped step kinds (load, untyped*, http*, etc). The typed CRUD step constructors (create/replace/get/list/...) require a CosmosMetadataAccessor pointer constraint that the raw TypedDocument used for UntypedCRUD suites doesn't satisfy, so we route that suite through this constraint-free path.

func (*ResourceMutationTest) RunTest

func (tt *ResourceMutationTest) RunTest(t *testing.T)

type ResourceType

type ResourceType struct {
	azcorearm.ResourceType
}

func (*ResourceType) MarshalText

func (o *ResourceType) MarshalText() ([]byte, error)

MarshalText returns a textual representation of the ResourceID

func (*ResourceType) UnmarshalText

func (o *ResourceType) UnmarshalText(text []byte) error

UnmarshalText decodes the textual representation of a ResourceID

type StepID

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

func NewStepID

func NewStepID(index int, stepType, stepName string) StepID

func (StepID) String

func (s StepID) String() string

type StepInput

type StepInput struct {
	CosmosContainer        *azcosmos.ContainerClient
	ContentLoader          integrationutils.ContentLoader
	DocumentLister         integrationutils.DocumentLister
	ResourcesDBClient      database.ResourcesDBClient
	FrontendURL            string
	AdminURL               string
	APIVersion             string
	ClusterServiceMockInfo *integrationutils.ClusterServiceMock
	KubeFakeClientSets     *integrationutils.KubernetesClientSets
}

func NewCosmosStepInput

func NewCosmosStepInput(storageInfo integrationutils.StorageIntegrationTestInfo) *StepInput

func (StepInput) HTTPTestAccessor

func (s StepInput) HTTPTestAccessor(key ResourceKey) HTTPTestAccessor

type UntypedCRUDKey

type UntypedCRUDKey struct {
	CosmosCRUDKey `json:",inline"`

	Descendents []UntypedChild `json:"descendents"`
}

type UntypedChild

type UntypedChild struct {
	ResourceType string `json:"resourceType"`
	ResourceName string `json:"resourceName"`
}

type UntypedItemKey

type UntypedItemKey struct {
	ResourceID string `json:"resourceId"`
}

Jump to

Keyboard shortcuts

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