Help us shape the future of Go! Take the 2026 Go Developer Survey

testrp

package
v0.62.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const Version = "2023-10-01-preview"

Variables

This section is empty.

Functions

func AsyncResource

func AsyncResource(t *testing.T, ts *testhost.TestHost, rootScope string, put BackendFunc, delete BackendFunc) func(w http.ResponseWriter, r *http.Request)

AsyncResource creates an HTTP handler that can be used to test asynchronous resource lifecycle operations.

func SyncResource

func SyncResource(t *testing.T, ts *testhost.TestHost, rootScope string) func(w http.ResponseWriter, r *http.Request)

SyncResource creates an HTTP handler that can be used to test synchronous resource lifecycle operations.

func TestResourceDataModelToVersioned

func TestResourceDataModelToVersioned(model *TestResourceDatamodel, version string) (v1.VersionedModelInterface, error)

TestResourceDataModelToVersioned converts version agnostic TestResource datamodel to versioned model.

Types

type BackendFunc

type BackendFunc func(ctx context.Context, request *backend_ctrl.Request) (backend_ctrl.Result, error)

type BackendFuncController

type BackendFuncController struct {
	backend_ctrl.BaseController
	Func BackendFunc
}

func (*BackendFuncController) Run

type Server

type Server struct {
	// Handler is the http.Handler implementation for the server. This can be set or updated at any time, but must be
	// set before processing requests.
	Handler http.HandlerFunc
	// contains filtered or unexported fields
}

Server is a test resource provider implementation. This will create a server on a local port that is scoped to a single test. Use Start to create and start a new server.

func Start

func Start(t *testing.T) *Server

Starts and returns a new test resource provider implementation. The caller is responsible for assigning the Handler field. The server will be stopped automatically when the test completes.

func (*Server) Address

func (s *Server) Address() string

Address returns the server's address as a string.

func (*Server) Close

func (s *Server) Close()

Close stops the server. This will be registered as a cleanup function with the test when Start is used to start the server.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP is the http.Handler implementation for the server. Test should not need to call this function.

type TestResource

type TestResource struct {
	ID         *string `json:"id"`
	Type       *string `json:"type"`
	Name       *string `json:"name"`
	Location   *string `json:"location"`
	Tags       map[string]*string
	Properties TestResourceProperties `json:"properties"`
}

func (*TestResource) ConvertFrom

func (dst *TestResource) ConvertFrom(src v1.DataModelInterface) error

ConvertFrom converts from version-agnostic datamodel to the versioned TestResource resource.

func (*TestResource) ConvertTo

func (src *TestResource) ConvertTo() (v1.DataModelInterface, error)

type TestResourceDatamodel

type TestResourceDatamodel struct {
	v1.BaseResource
	Properties TestResourceDatamodelProperties `json:"properties"`
}

func TestResourceDataModelFromVersioned

func TestResourceDataModelFromVersioned(content []byte, version string) (*TestResourceDatamodel, error)

TestResourceDataModelFromVersioned converts versioned TestResource model to datamodel.

type TestResourceDatamodelProperties

type TestResourceDatamodelProperties struct {
	Message *string `json:"message,omitempty"`
}

type TestResourceList

type TestResourceList struct {
	Value []TestResource `json:"value"`
}

type TestResourceProperties

type TestResourceProperties struct {
	Message           *string `json:"message,omitempty"`
	ProvisioningState *string `json:"provisioningState,omitempty"`
}

Jump to

Keyboard shortcuts

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