testutil

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: May 4, 2018 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get(t *testing.T, actual []byte) []byte

Get returns the golden file content. If the `test.update` is specified, it updates the file with the current output and returns it.

Types

type TestServer

type TestServer struct {
	spi.RunningServer
	// contains filtered or unexported fields
}

TestServer represents a test Consulate server.

func (*TestServer) AddCheck

func (s *TestServer) AddCheck(t *testing.T, id string, name string, serviceID string, status checks.HealthStatus)

AddCheck adds a check to the test Consul server.

func (*TestServer) AddService

func (s *TestServer) AddService(t *testing.T, name string, tags []string)

AddService adds a service to the test Consul server.

func (*TestServer) Client

func (s *TestServer) Client() *http.Client

Client returns the http.Client used to communicate with the test Consulate server.

func (*TestServer) GetConsulNodeName

func (s *TestServer) GetConsulNodeName() string

GetConsulNodeName returns the test Consul server's node name.

func (*TestServer) RequireOK

func (s *TestServer) RequireOK(t *testing.T, resp *http.Response) error

RequireOK checks that the status code of the specified http.Response is 200.

func (*TestServer) Stop

func (s *TestServer) Stop()

Stop terminates the current RunningServer.

func (*TestServer) Url

func (s *TestServer) Url(t *testing.T, path string) string

Url appends the specified path to the base url used to communicate with the test Consulate server.

func (*TestServer) Wrap

func (s *TestServer) Wrap(t *testing.T) *WrappedTestServer

Wrap combines the specified testing.T with the current TestServer into a WrappedTestServer which simplifies test code.

type WrappableTestServer

type WrappableTestServer struct {
	TestServer
}

WrappableTestServer represents a test Consulate server that can wrap testing.T, simplifying the usage in test code.

func NewTestServer

func NewTestServer(t *testing.T) (*WrappableTestServer, error)

NewTestServer creates a new test Consulate server.

type WrappedTestServer

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

WrappedTestServer represents the combination of a test Consulate server and testing.T.

func (*WrappedTestServer) AddCheck

func (w *WrappedTestServer) AddCheck(id string, name string, serviceID string, status checks.HealthStatus)

AddCheck adds a check to the test Consul server.

func (*WrappedTestServer) AddService

func (w *WrappedTestServer) AddService(name string, tags []string)

AddService adds a service to the test Consul server.

func (*WrappedTestServer) Client

func (w *WrappedTestServer) Client() *http.Client

Client returns the http.Client used to communicate with the test Consulate server.

func (*WrappedTestServer) GetConsulNodeName

func (w *WrappedTestServer) GetConsulNodeName() string

GetConsulNodeName returns the test Consul server's node name.

func (*WrappedTestServer) RequireOK

func (w *WrappedTestServer) RequireOK(resp *http.Response) error

RequireOK checks that the status code of the specified http.Response is 200.

func (*WrappedTestServer) Stop

func (w *WrappedTestServer) Stop()

Stop terminates the current RunningServer.

func (*WrappedTestServer) Url

func (w *WrappedTestServer) Url(path string) string

Url appends the specified path to the base url used to communicate with the test Consulate server.

Jump to

Keyboard shortcuts

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