testutils

package
v0.0.0-...-d6fed6f Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2015 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsError

func IsError(err error, re string) bool

IsError returns true if err is non-nil and the error string matches the supplied regexp.

func NewNodeTestBaseContext

func NewNodeTestBaseContext() *base.Context

NewNodeTestBaseContext creates a base context for testing. This uses embedded certs and the "node" user (default node user). The "node" user has both server and client certificates.

func NewRootTestBaseContext

func NewRootTestBaseContext() *base.Context

NewRootTestBaseContext creates a base context for testing. This uses embedded certs and the "root" user (default client user). The "root" user has client certificates only.

func NewTestHTTPClient

func NewTestHTTPClient() (*http.Client, error)

NewTestHTTPClient creates a HTTP client on the fly using a test context. Useful when contexts don't need to be reused.

func SetDefaultRangeMaxBytes

func SetDefaultRangeMaxBytes(db DB, maxBytes int64) error

SetDefaultRangeMaxBytes sets the range-max-bytes value for the default zone.

func SetDefaultRangeReplicaNum

func SetDefaultRangeReplicaNum(db DB, numReplicas int) error

SetDefaultRangeReplicaNum sets the replication factor for the default zone.

Types

type DB

type DB interface {
	GetProto(interface{}, gogoproto.Message) error
	Put(interface{}, interface{}) error
}

DB provides the functionality needed to read and write zone configs.

type TestHTTPSession

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

TestHTTPSession is a helper for tests which want to exercise repeated simple HTTP requests against the same server, especially where no errors are expected in the HTTP layer.

func NewTestHTTPSession

func NewTestHTTPSession(t util.Tester, ctx *base.Context, baseURL string) *TestHTTPSession

NewTestHTTPSession constructs a new TestHTTPSession. The session will instantiate a client using the based base context. All HTTP requests from the session will be sent to the given baseUrl.

baseUrl should be specified *without* a request scheme (i.e. "http://"); the request scheme will be used from the context.

If an error occurs in HTTP layer during any session operation, a Fatal method will be called on the supplied t.Tester.

func (*TestHTTPSession) Get

func (ths *TestHTTPSession) Get(relative string) []byte

Get performs an http GET request to the given relative URL. Any response returned from the request will be returned from this method as a byte slice.

func (*TestHTTPSession) Post

func (ths *TestHTTPSession) Post(relative string, body []byte) []byte

Post performs an http POST of the given bytes to the given relative URL. Any response returned from the request will be returned from this method as a byte slice.

func (*TestHTTPSession) PostProto

func (ths *TestHTTPSession) PostProto(relative string, msg gogoproto.Message, out interface{})

PostProto handles the common case where both the data posted and the expected response are encoded protobuffers. This method handles the marshalling of those buffers.

Jump to

Keyboard shortcuts

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