httptest

package
v6.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2017 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ExplicitURL If true then the url (should) be prepended manually, useful when want to test subdomains
	// Default is false
	ExplicitURL = func(val bool) OptionSet {
		return func(c *Configuration) {
			c.ExplicitURL = val
		}
	}
	// Debug if true then debug messages from the httpexpect will be shown when a test runs
	// Default is false
	Debug = func(val bool) OptionSet {
		return func(c *Configuration) {
			c.Debug = val
		}
	}
)

Functions

func New

func New(app *iris.Framework, t *testing.T, setters ...OptionSetter) *httpexpect.Expect

New Prepares and returns a new test framework based on the app is useful when you need to have more than one test framework for the same iris instance usage: iris.Default.Get("/mypath", func(ctx *iris.Context){ctx.Write("my body")}) ... e := httptest.New(iris.Default, t) e.GET("/mypath").Expect().Status(iris.StatusOK).Body().Equal("my body")

You can find example on the https://github.com/kataras/iris/glob/master/context_test.go

func NewInsecure

func NewInsecure(baseURL string, t *testing.T, setters ...OptionSetter) *httpexpect.Expect

NewInsecure same as New but receives a single host instead of the whole framework

Types

type Configuration

type Configuration struct {
	// ExplicitURL If true then the url (should) be prepended manually, useful when want to test subdomains
	// Default is false
	ExplicitURL bool
	// Debug if true then debug messages from the httpexpect will be shown when a test runs
	// Default is false
	Debug bool
}

Configuration httptest configuration

func DefaultConfiguration

func DefaultConfiguration() *Configuration

DefaultConfiguration returns the default configuration for the httptest all values are defaulted to false for clarity

func (Configuration) Set

func (c Configuration) Set(main *Configuration)

Set implements the OptionSetter for the Configuration itself

type OptionSet

type OptionSet func(c *Configuration)

OptionSet implements the OptionSetter

func (OptionSet) Set

func (o OptionSet) Set(c *Configuration)

Set is the func which makes the OptionSet an OptionSetter, this is used mostly

type OptionSetter

type OptionSetter interface {
	// Set receives a pointer to the Configuration type and does the job of filling it
	Set(c *Configuration)
}

OptionSetter sets a configuration field to the configuration

Jump to

Keyboard shortcuts

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