httpcache: github.com/GeekyPanda/httpcache/httptest Index | Files

package httptest

import "github.com/GeekyPanda/httpcache/httptest"

Index

Package Files

httptest.go

Variables

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
        }
    }
    // Handler sets the http handler to the httptest , use this function if you test your net/http api
    Handler = func(val http.Handler) OptionSet {
        return func(c *Configuration) {
            c.Handler = val
        }
    }
    // RequestHandler sets the fasthttp handler to the httptest , use this function if you test your valyala/fasthttp api
    RequestHandler = func(val fasthttp.RequestHandler) OptionSet {
        return func(c *Configuration) {
            c.RequestHandler = val
        }
    }
)

func New Uses

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

New Prepares and returns a new test framework based on a handler mux := http.NewServeMux() mux.Handle("/",http.HandlerFunc(...)) ... e := httptest.New(t, httptest.Handler(mux)) e.GET("/mypath").Expect().Status(http.StatusOK).Body().Equal("my body")

type Configuration Uses

type Configuration struct {
    // Handler is the net/http handler, if != nil then httptest is testing via net/http's options
    Handler http.Handler
    // RequestHandler is the valyala/fasthttp.RequestHandler, if != nil then httptest is testing via valyala/fasthttp's options
    RequestHandler fasthttp.RequestHandler
    // 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 is the httptest main configuration

func DefaultConfiguration Uses

func DefaultConfiguration() *Configuration

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

func (Configuration) Set Uses

func (c Configuration) Set(main *Configuration)

Set implements the OptionSetter for the Configuration itself

type OptionSet Uses

type OptionSet func(c *Configuration)

OptionSet implements the OptionSetter

func (OptionSet) Set Uses

func (o OptionSet) Set(c *Configuration)

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

type OptionSetter Uses

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

Package httptest imports 4 packages (graph). Updated 2017-04-29. Refresh now. Tools for package owners. This is an inactive package (no imports and no commits in at least two years).