storetesting

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2014 License: LGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var JSONEquals = &codecEqualChecker{
	name:      "JSONEquals",
	marshal:   json.Marshal,
	unmarshal: json.Unmarshal,
}

JSONEquals defines a checker that checks whether a byte slice, when unmarshaled as JSON, is equal to the given value. Rather than unmarshaling into something of the expected body type, we reform the expected body in JSON and back to interface{}, so we can check the whole content. Otherwise we lose information when unmarshaling.

View Source
var YAMLEquals = &codecEqualChecker{
	name:      "YAMLEquals",
	marshal:   yaml.Marshal,
	unmarshal: yaml.Unmarshal,
}

YAMLEquals defines a checker that checks whether a byte slice, when unmarshaled as YAML, is equal to the given value. Rather than unmarshaling into something of the expected body type, we reform the expected body in YAML and back to interface{}, so we can check the whole content. Otherwise we lose information when unmarshaling.

Functions

func AssertJSONCall

func AssertJSONCall(c *gc.C, p JSONCallParams)

AssertJSONCall asserts that when the given handler is called with the given parameters, the result is as specified.

func AssertResponse

func AssertResponse(c *gc.C, rec *httptest.ResponseRecorder, expectStatus int, expectBody interface{})

AssertResponse asserts that the given response recorder has recorded the given HTTP status and response body.

func DoRequest

func DoRequest(c *gc.C, p DoRequestParams) *httptest.ResponseRecorder

DoRequest invokes a request on the given handler with the given parameters.

func MongoJSEnabled

func MongoJSEnabled() bool

MongoJSEnabled reports whether testing code should run tests that rely on JavaScript inside MongoDB.

Types

type DoRequestParams

type DoRequestParams struct {
	// Handler holds the handler to use to make the request.
	Handler http.Handler

	// Method holds the HTTP method to use for the call.
	// GET is assumed if this is empty.
	Method string

	// URL holds the URL to pass when making the request.
	URL string

	// Body holds the body to send in the request.
	Body io.Reader

	// Header specifies the HTTP headers to use when making
	// the request.
	Header http.Header

	// ContentLength specifies the length of the body.
	// It may be zero, in which case the default net/http
	// content-length behaviour will be used.
	ContentLength int64

	// Username, if specified, is used for HTTP basic authentication.
	Username string

	// Password, if specified, is used for HTTP basic authentication.
	Password string
}

DoRequestParams holds parameters for DoRequest. If left empty, some fields will automatically be filled with defaults.

type ElasticSearchSuite

type ElasticSearchSuite struct {
	ES *elasticsearch.Database

	TestIndex string
	// contains filtered or unexported fields
}

ElasticSearchSuite defines a test suite that connects to an elastic-search server. The address of the server depends on the value of the JUJU_TEST_ELASTICSEARCH environment variable, which can be "none" (do not start or connect to a server) or host:port holding the address and port of the server to connect to. If JUJU_TEST_ELASTICSEARCH is not specified then localhost:9200 will be used.

func (*ElasticSearchSuite) LoadESConfig

func (s *ElasticSearchSuite) LoadESConfig(index string) error

LoadESConfig loads a canned test configuration to the specified index

func (*ElasticSearchSuite) NewIndex

func (s *ElasticSearchSuite) NewIndex(c *gc.C) string

NewIndex creates a new index name and ensures that it will be cleaned up at end of the test.

func (*ElasticSearchSuite) SetUpSuite

func (s *ElasticSearchSuite) SetUpSuite(c *gc.C)

func (*ElasticSearchSuite) SetUpTest

func (s *ElasticSearchSuite) SetUpTest(c *gc.C)

func (*ElasticSearchSuite) TearDownSuite

func (s *ElasticSearchSuite) TearDownSuite(c *gc.C)

func (*ElasticSearchSuite) TearDownTest

func (s *ElasticSearchSuite) TearDownTest(c *gc.C)

type IsolatedMgoESSuite

func (*IsolatedMgoESSuite) SetUpSuite

func (s *IsolatedMgoESSuite) SetUpSuite(c *gc.C)

func (*IsolatedMgoESSuite) SetUpTest

func (s *IsolatedMgoESSuite) SetUpTest(c *gc.C)

func (*IsolatedMgoESSuite) TearDownSuite

func (s *IsolatedMgoESSuite) TearDownSuite(c *gc.C)

func (*IsolatedMgoESSuite) TearDownTest

func (s *IsolatedMgoESSuite) TearDownTest(c *gc.C)

type IsolatedMgoSuite

type IsolatedMgoSuite struct {
	jujutesting.IsolationSuite
	jujutesting.MgoSuite
}

func (*IsolatedMgoSuite) SetUpSuite

func (s *IsolatedMgoSuite) SetUpSuite(c *gc.C)

func (*IsolatedMgoSuite) SetUpTest

func (s *IsolatedMgoSuite) SetUpTest(c *gc.C)

func (*IsolatedMgoSuite) TearDownSuite

func (s *IsolatedMgoSuite) TearDownSuite(c *gc.C)

func (*IsolatedMgoSuite) TearDownTest

func (s *IsolatedMgoSuite) TearDownTest(c *gc.C)

type JSONCallParams

type JSONCallParams struct {
	// Handler holds the handler to use to make the request.
	Handler http.Handler

	// Method holds the HTTP method to use for the call.
	// GET is assumed if this is empty.
	Method string

	// URL holds the URL to pass when making the request.
	URL string

	// Body holds the body to send in the request.
	Body io.Reader

	// Header specifies the HTTP headers to use when making
	// the request.
	Header http.Header

	// ContentLength specifies the length of the body.
	// It may be zero, in which case the default net/http
	// content-length behaviour will be used.
	ContentLength int64

	// Username, if specified, is used for HTTP basic authentication.
	Username string

	// Password, if specified, is used for HTTP basic authentication.
	Password string

	// ExpectStatus holds the expected HTTP status code.
	// http.StatusOK is assumed if this is zero.
	ExpectStatus int

	// ExpectBody holds the expected JSON body.
	ExpectBody interface{}
}

JSONCallParams holds parameters for AssertJSONCall. If left empty, some fields will automatically be filled with defaults.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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