test

package
v0.46.1 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2022 License: Apache-2.0 Imports: 18 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MockBundle

func MockBundle(file string, policies map[string]string) func(*Server) error

MockBundle sets a bundle named file on the test server containing the given policies.

func MockOCIBundle added in v0.41.0

func MockOCIBundle(ref string, policies map[string]string) func(*Server) error

MockOCIBundle prepares the server to allow serving "/v2" OCI responses from the supplied policies Ref parameter must be in the form of <registry>/<org>/<repo>:<tag> that will be used in detecting future calls

func Ready

func Ready(ch chan struct{}) func(*Server) error

Ready provides a channel that the server will use to gate readiness. The caller can provide this channel to prevent the server from becoming ready. The server will response with HTTP 500 responses until ready. The caller should close the channel to indicate readiness.

Types

type Server

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

Server provides a mock HTTP server for testing the SDK and integrations.

func MustNewServer

func MustNewServer(opts ...func(*Server) error) *Server

MustNewServer returns a new Server for test purposes or panics if an error occurs.

func NewServer

func NewServer(opts ...func(*Server) error) (*Server, error)

NewServer returns a new Server for test purposes.

func (*Server) Stop

func (s *Server) Stop()

Stop stops the test server.

func (*Server) URL

func (s *Server) URL() string

URL returns the base URL of the server.

func (*Server) WithTestBundle

func (s *Server) WithTestBundle(endpoint string, policies map[string]string) *Server

WithTestBundle adds a bundle to the server at the specified endpoint.

Jump to

Keyboard shortcuts

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