testutil

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2021 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertClusterWorkflowsEqual

func AssertClusterWorkflowsEqual(t *testing.T, expected *vtadminpb.ClusterWorkflows, actual *vtadminpb.ClusterWorkflows, msgAndArgs ...interface{})

AssertClusterWorkflowsEqual is a test helper for asserting that two ClusterWorkflows objects are equal.

func AssertGetWorkflowsResponsesEqual

func AssertGetWorkflowsResponsesEqual(t *testing.T, expected *vtadminpb.GetWorkflowsResponse, actual *vtadminpb.GetWorkflowsResponse, msgAndArgs ...interface{})

AssertGetWorkflowsResponsesEqual is a test helper for asserting that two GetWorkflowsResponse objects are equal.

func AssertKeyspaceSlicesEqual

func AssertKeyspaceSlicesEqual(t *testing.T, expected []*vtadminpb.Keyspace, actual []*vtadminpb.Keyspace)

AssertKeyspaceSlicesEqual is a convenience function to assert that two []*vtadminpb.Keyspaces slices are equal

func AssertSchemaSlicesEqual

func AssertSchemaSlicesEqual(t *testing.T, expected []*vtadminpb.Schema, actual []*vtadminpb.Schema)

AssertSchemaSlicesEqual is a convenience function to assert that two []*vtadminpb.Schema slices are equal

func AssertSrvVSchemaSlicesEqual added in v0.11.0

func AssertSrvVSchemaSlicesEqual(t *testing.T, expected []*vtadminpb.SrvVSchema, actual []*vtadminpb.SrvVSchema)

AssertSrvVSchemaSlicesEqual is a convenience function to assert that two []*vtadminpb.SrvVSchema slices are equal

func AssertTabletSlicesEqual

func AssertTabletSlicesEqual(t *testing.T, expected []*vtadminpb.Tablet, actual []*vtadminpb.Tablet)

AssertTabletSlicesEqual is a convenience function to assert that two []*vtadminpb.Tablet slices are equal

func BuildCluster

func BuildCluster(t testing.TB, cfg TestClusterConfig) *cluster.Cluster

BuildCluster is a shared helper for building a cluster based on the given test configuration.

func BuildClusters

func BuildClusters(t testing.TB, cfgs ...TestClusterConfig) []*cluster.Cluster

BuildClusters is a helper for building multiple clusters from a slice of TestClusterConfigs.

func TopodataTabletsFromVTAdminTablets

func TopodataTabletsFromVTAdminTablets(tablets []*vtadminpb.Tablet) []*topodatapb.Tablet

TopodataTabletsFromVTAdminTablets returns a slice of topodatapb.Tablet objects from a slice of vtadminpb.Tablet objects. It is the equivalent of

map(func(t *vtadminpb.Tablet) (*topodatapb.Tablet) { return t.Tablet }, tablets)

Types

type Dbcfg

type Dbcfg struct {
	ShouldErr bool
}

Dbcfg is a test utility for controlling the behavior of the cluster's DB at the package sql level.

type TestClusterConfig

type TestClusterConfig struct {
	// Cluster provides the protobuf-based version of the cluster info. It is
	// to set the ID and Name of the resulting cluster.Cluster, as well as to
	// name a single, phony, vtgate entry in the cluster's discovery service.
	Cluster *vtadminpb.Cluster
	// VtctldClient provides the vtctldclient.VtctldClient implementation the
	// cluster's vtctld proxy will use. Most unit tests will use an instance of
	// the VtctldClient type provided by this package in order to mock out the
	// vtctld layer.
	VtctldClient vtctldclient.VtctldClient
	// Tablets provides the set of tablets reachable by this cluster's vtsql.DB.
	// Tablets are copied, and then mutated to have their Cluster field set to
	// match the Cluster provided by this TestClusterConfig, so mutations are
	// transparent to the caller.
	Tablets []*vtadminpb.Tablet
	// DBConfig controls the behavior of the cluster's vtsql.DB.
	DBConfig Dbcfg
}

TestClusterConfig controls the way that a cluster.Cluster object is constructed for testing vtadmin code.

Jump to

Keyboard shortcuts

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