fixtures

package
v0.0.0-...-b80afe7 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package fixtures provides access to consistent data structures for testing against. Data read from this package must either be constant, or a deep copy of the original template.

Index

Constants

View Source
const (
	// ServiceInstanceName is a name to use for a service instance.
	ServiceInstanceName = "pinkiepie"

	// AlternateServiceInstanceName is a name to use for another service instance.
	AlternateServiceInstanceName = "rainbowdash"

	// ServiceBindingName is a name to use for a service binding.
	ServiceBindingName = "spike"

	// IllegalID is an illegal ID and must not be used as a service or plan ID.
	IllegalID = "illegal"

	// BasicConfigurationOfferingID is the symbolic constant UUID used for the basic configuration.
	BasicConfigurationOfferingID = `dd2cce49-a0ff-4deb-9cbf-b97301fdb87e`

	// BasicConfigurationPlanID is the symbolic constant UUID used for the basic configuration plan.
	BasicConfigurationPlanID = `3f525c60-bd66-4b91-8d18-beba57fbc0b8`

	// BasicConfigurationPlanID2 is the symbolic constant UUID used for the basic configuration plan.
	BasicConfigurationPlanID2 = `e18fce8d-1f4a-44fa-88c8-e7a52ed50f29`

	// BasicSchemaParameters is a simple schema for use in parameter validation.
	BasicSchemaParameters = `{"$schema":"http://json-schema.org/draft-04/schema#","type":"object","properties":{"test":{"type":"number","minimum":1}}}`

	// BasicSchemaParametersRequired is a simple schema for use in parameter validation.
	BasicSchemaParametersRequired = `` /* 141-byte string literal not displayed */

	// DashboardURL is the expected dashboard URL to be generated.
	DashboardURL = "http://instance-" + ServiceInstanceName + "." + util.Namespace + ".svc"

	// OptionalParameter is a template parameter this is optional.
	OptionalParameter = "hostname"
)

Variables

View Source
var (

	// IllegalTemplateName refers to a template for a non-existent resource
	// type that can be used to simulate Kubernetes errors.
	IllegalTemplateName = "illegal"
)

Functions

func AddRegistry

func AddRegistry(spec *v1.ServiceBrokerConfigSpec, name string, expression interface{})

AddRegistry appends the requested template expression to the service instance binding registry entry for the first binding.

func AssertFixtureFieldNotSet

func AssertFixtureFieldNotSet(t *testing.T, clients client.Clients, path ...string)

AssertFixtureFieldNotSet asserts that the named field in the Kubernetes resource is not set as expected.

func AssertFixtureFieldSet

func AssertFixtureFieldSet(t *testing.T, clients client.Clients, value interface{}, path ...string)

AssertFixtureFieldSet asserts that the named field in the Kubernetes resource is set as expected.

func BasicConfiguration

func BasicConfiguration() *v1.ServiceBrokerConfigSpec

BasicConfiguration is the absolute minimum valid configuration allowed by the service broker configuration schema.

func BasicConfigurationWithReadiness

func BasicConfigurationWithReadiness() *v1.ServiceBrokerConfigSpec

BasicConfigurationWithReadiness returns the standard configuration with a readiness check added for the resource that is templated.

func BasicResourceStatus

func BasicResourceStatus(t *testing.T) interface{}

BasicResourceStatus returns the templated resource status that will fulfil the readiness checks defined above. The unstructured application code needs things to be fully unstructured, it's not clever enough to use a raw object type.

func BasicSchema

func BasicSchema() *v1.Schemas

BasicSchema is schema for service instance create validation with optional parameters.

func BasicSchemaBindingRequired

func BasicSchemaBindingRequired() *v1.Schemas

BasicSchemaBindingRequired is a schema for service binding create validation with required parameters.

func BasicSchemaRequired

func BasicSchemaRequired() *v1.Schemas

BasicSchemaRequired is a schema for service instance create validation with required parameters.

func BasicServiceBindingCreateRequest

func BasicServiceBindingCreateRequest() *api.CreateServiceBindingRequest

BasicServiceBindingCreateRequest is the absolute minimum valid service bindinf create request to use against the basicConfiguration.

func BasicServiceInstanceCreateRequest

func BasicServiceInstanceCreateRequest() *api.CreateServiceInstanceRequest

BasicServiceInstanceCreateRequest is the absolute minimum valid service instance create request to use against the basicConfiguration.

func BasicServiceInstanceUpdateRequest

func BasicServiceInstanceUpdateRequest() *api.UpdateServiceInstanceRequest

BasicServiceInstanceUpdateRequest is the absolute minimum valid service instance update request to use against the basicConfiguration.

func EmptyConfiguration

func EmptyConfiguration() *v1.ServiceBrokerConfigSpec

EmptyConfiguration returns an empty configuration, useful for testing when users really screw up.

func MustSetFixtureField

func MustSetFixtureField(t *testing.T, clients client.Clients, value interface{}, path ...string)

MustSetFixtureField sets the named field in the fixture Kubernetes resource.

func SetRegistry

func SetRegistry(spec *v1.ServiceBrokerConfigSpec, name string, expression interface{})

SetRegistry sets the service instance binding registry entries for the first binding to the requested template expression.

Types

type Function

type Function string

Function represents a named function that accepts an arbitrary number of arguments. https://golang.org/pkg/text/template/#hdr-Functions

func Default

func Default(arg interface{}) Function

Default generates a function that returns a default if the input it nil.

func GenerateCertificate

func GenerateCertificate(key, cn, lifetime, usage, sans, caKey, caCert interface{}) Function

GenerateCertificate returns a function that generates a certificate.

func GeneratePassword

func GeneratePassword(length, dictionary interface{}) Function

GeneratePassword returns a function that generates a random password string.

func GeneratePrivateKey

func GeneratePrivateKey(typ, encoding, bits interface{}) Function

GeneratePrivateKey returns a function that generates a private key.

func NewFunction

func NewFunction(fn string, args ...interface{}) Function

NewFunction creates a new named function.

func Parameter

func Parameter(arg interface{}) Function

Parameter returns a function that looks up a parameter path.

func Registry

func Registry(arg interface{}) Function

Registry returns a function that looks up a registry entry.

func Required

func Required() Function

Required returns a function that raises an error if the input is nil.

type Pipeline

type Pipeline string

Pipeline represents a pipeline of of go template functions. https://golang.org/pkg/text/template/#hdr-Pipelines

func NewGenerateCertificatePipeline

func NewGenerateCertificatePipeline(key, cn, lifetime, usage, sans, caKey, caCert interface{}) Pipeline

NewGenerateCertificatePipeline creates a pipeline initialized with a generate certificate function.

func NewGeneratePasswordPipeline

func NewGeneratePasswordPipeline(length, dictionary interface{}) Pipeline

NewGeneratePasswordPipeline creates a pipeline initialized with a generate password function.

func NewGeneratePrivateKeyPipeline

func NewGeneratePrivateKeyPipeline(typ, encoding, bits interface{}) Pipeline

NewGeneratePrivateKeyPipeline creates a pipeline initialized with a generate private key function.

func NewParameterPipeline

func NewParameterPipeline(arg interface{}) Pipeline

NewParameterPipeline creates a pipeline initialized with a parameter lookup function.

func NewPipeline

func NewPipeline(fn Function) Pipeline

NewPipeline creates a new pipeline from a function. While a pipeline can start with an argument, all our data accessors are through functions so this is the common path.

func NewRegistryPipeline

func NewRegistryPipeline(arg interface{}) Pipeline

NewRegistryPipeline creates a pipeline initialized with a registry lookup function.

func (Pipeline) Required

func (p Pipeline) Required() Pipeline

Required appends a function to a pipeline that sets a default if the input is nil.

func (Pipeline) With

func (p Pipeline) With(fn Function) Pipeline

With appends a function to a pipeline.

func (Pipeline) WithDefault

func (p Pipeline) WithDefault(arg interface{}) Pipeline

WithDefault appends a defaulting function to a pipeline.

Jump to

Keyboard shortcuts

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