Documentation ¶
Index ¶
- Constants
- Variables
- func StringReplace(c *Case, in string) (string, error)
- type BaseClient
- type BaseResponseHandler
- type BaseStringReplacer
- type BinaryDataHandler
- type Case
- func (c *Case) Done() bool
- func (c *Case) Errorf(format string, args ...any)
- func (c *Case) Fatalf(format string, args ...any)
- func (c *Case) GetDefaultURLBase() string
- func (c *Case) GetParent() *testing.T
- func (c *Case) GetPrior(caseName string) *Case
- func (c *Case) GetRequestBody() (io.Reader, error)
- func (c *Case) GetResponseBody() io.ReadSeeker
- func (c *Case) GetResponseHeader() http.Header
- func (c *Case) GetTest() *testing.T
- func (c *Case) GetXFailure() bool
- func (c *Case) NewRequestDataHandler() (RequestDataHandler, error)
- func (c *Case) ParsedURL() *url.URL
- func (c *Case) ReadFileForData(fileName string) (io.Reader, error)
- func (c *Case) SetDefaultURLBase(s string)
- func (c *Case) SetDone()
- func (c *Case) SetPrior(p *Case)
- func (c *Case) SetResponseBody(body io.ReadSeeker)
- func (c *Case) SetResponseHeader(h http.Header)
- func (c *Case) SetSuiteFileName(fileName string)
- func (c *Case) SetTest(t *testing.T, parent *testing.T)
- func (c *Case) SetXFailure()
- type EnvironReplacer
- type HeaderResponseHandler
- type HeadersReplacer
- type JSONHandler
- func (*JSONHandler) Accepts(c *Case) bool
- func (j *JSONHandler) Assert(c *Case)
- func (j *JSONHandler) GetBody(c *Case) (io.Reader, error)
- func (j *JSONHandler) ProcessOnePath(c *Case, rawJSON interface{}, path string, v interface{}) error
- func (j *JSONHandler) ReadJSONFromDisk(c *Case, stringData string) (string, error)
- func (j *JSONHandler) ReadJSONReponse(c *Case) (interface{}, error)
- func (j *JSONHandler) Replace(c *Case, in string) (string, error)
- func (j *JSONHandler) Resolve(prior *Case, argValue, cast string) (string, error)
- type LastURLReplacer
- type LocationReplacer
- type MultiSuite
- type NetlocReplacer
- type NilDataHandler
- type Poll
- type RequestDataHandler
- type Requester
- type ResponseHandler
- type SchemeReplacer
- type StringReplacer
- type StringResponseHandler
- type Suite
- type SuiteYAML
- type TextDataHandler
- type URLReplacer
Constants ¶
View Source
const (
// TODO: change this
DefaultHTTPTimeout = 30
)
Variables ¶
View Source
var ( ErrTestError = errors.New("error during request") ErrTestFailure = errors.New("failure during request") ErrUnexpectedStatus = fmt.Errorf("%w: unexpected status", ErrTestFailure) ErrNoDataHandler = fmt.Errorf("%w: no handler for request content-type", ErrTestError) ErrDataHandlerContentMismatch = fmt.Errorf("%w: data and request content-type mismatch", ErrTestError) ErrStringNotFound = fmt.Errorf("%w: string not found in body", ErrTestFailure) ErrJSONPathNotMatched = fmt.Errorf("%w: json path not matched", ErrTestFailure) ErrNoPriorTest = fmt.Errorf("%w: no prior test", ErrTestError) ErrHeaderNotPresent = fmt.Errorf("%w: missing header", ErrTestFailure) ErrHeaderValueMismatch = fmt.Errorf("%w: header value mismatch", ErrTestFailure) ErrEnvironmentVariableNotFound = fmt.Errorf("%w: environment variable not found", ErrTestError) )
TODO: Maybe Test instead of Request? Not sure what I was thinking...
Functions ¶
Types ¶
type BaseClient ¶
func NewClient ¶
func NewClient() *BaseClient
func (*BaseClient) Do ¶
func (b *BaseClient) Do(c *Case)
func (*BaseClient) ExecuteOne ¶
func (b *BaseClient) ExecuteOne(c *Case)
type BaseResponseHandler ¶
type BaseResponseHandler struct{}
func (*BaseResponseHandler) Accepts ¶
func (b *BaseResponseHandler) Accepts(c *Case) bool
type BaseStringReplacer ¶
type BaseStringReplacer struct {
// contains filtered or unexported fields
}
func (*BaseStringReplacer) GetRegExp ¶
func (br *BaseStringReplacer) GetRegExp() *regexp.Regexp
type BinaryDataHandler ¶
type BinaryDataHandler struct{}
type Case ¶
type Case struct { Name string `yaml:"name,omitempty"` Desc string `yaml:"desc,omitempty"` Method string `yaml:"method,omitempty"` URL string `yaml:"url,omitempty"` GET string `yaml:"GET,omitempty"` POST string `yaml:"POST,omitempty"` PUT string `yaml:"PUT,omitempty"` DELETE string `yaml:"DELETE,omitempty"` HEAD string `yaml:"HEAD,omitempty"` PATCH string `yaml:"PATCH,omitempty"` OPTIONS string `yaml:"OPTIONS,omitempty"` Status int `yaml:"status,omitempty"` RequestHeaders map[string]string `yaml:"request_headers,omitempty"` QueryParameters map[string]interface{} `yaml:"query_parameters,omitempty"` Data interface{} `yaml:"data,omitempty"` Xfail bool `yaml:"xfail,omitempty"` Verbose bool `yaml:"verbose,omitempty"` Skip *string `yaml:"skip,omitempty"` CertValidated bool `yaml:"cert_validated,omitempty"` Redirects int `yaml:"redirects,omitempty"` UsePriorTest *bool `yaml:"use_prior_test,omitempty"` Poll Poll `yaml:"poll,omitempty"` // SSL is ignored but we parse it for compatibility with gabbi. SSL *bool `yaml:"ssl,omitempty"` // TODO: Ideally these would be pluggable, as with gabbi, but it is too // hard to figure out how to do that, so we'll fake it for now. ResponseHeaders map[string]string `yaml:"response_headers,omitempty"` ResponseForbiddenHeaders []string `yaml:"response_forbidden_headers,omitempty"` ResponseStrings []string `yaml:"response_strings,omitempty"` ResponseJSONPaths map[string]interface{} `yaml:"response_json_paths,omitempty"` // contains filtered or unexported fields }
func (*Case) GetDefaultURLBase ¶
func (*Case) GetResponseBody ¶
func (c *Case) GetResponseBody() io.ReadSeeker
func (*Case) GetResponseHeader ¶
func (*Case) GetXFailure ¶
func (*Case) NewRequestDataHandler ¶
func (c *Case) NewRequestDataHandler() (RequestDataHandler, error)
func (*Case) ReadFileForData ¶
Open a data file for reading. TODO: sandbox the dir!
func (*Case) SetDefaultURLBase ¶
func (*Case) SetResponseBody ¶
func (c *Case) SetResponseBody(body io.ReadSeeker)
func (*Case) SetResponseHeader ¶
func (*Case) SetSuiteFileName ¶
func (*Case) SetXFailure ¶
func (c *Case) SetXFailure()
type EnvironReplacer ¶
type EnvironReplacer struct {
BaseStringReplacer
}
type HeaderResponseHandler ¶
type HeaderResponseHandler struct {
BaseResponseHandler
}
func (*HeaderResponseHandler) Assert ¶
func (h *HeaderResponseHandler) Assert(c *Case)
type HeadersReplacer ¶
type HeadersReplacer struct {
BaseStringReplacer
}
type JSONHandler ¶
type JSONHandler struct { BaseStringReplacer BaseResponseHandler }
func (*JSONHandler) Accepts ¶
func (*JSONHandler) Accepts(c *Case) bool
func (*JSONHandler) Assert ¶
func (j *JSONHandler) Assert(c *Case)
func (*JSONHandler) ProcessOnePath ¶
func (j *JSONHandler) ProcessOnePath(c *Case, rawJSON interface{}, path string, v interface{}) error
func (*JSONHandler) ReadJSONFromDisk ¶
func (j *JSONHandler) ReadJSONFromDisk(c *Case, stringData string) (string, error)
ReadJSONFromDisk, selecting a json path from it, if there is a : in the filename.
func (*JSONHandler) ReadJSONReponse ¶
func (j *JSONHandler) ReadJSONReponse(c *Case) (interface{}, error)
type LastURLReplacer ¶
type LastURLReplacer struct {
BaseStringReplacer
}
type LocationReplacer ¶
type LocationReplacer struct {
BaseStringReplacer
}
type MultiSuite ¶
type MultiSuite struct {
Suites []*Suite
}
func (*MultiSuite) Execute ¶
func (m *MultiSuite) Execute(t *testing.T)
Execute a MultiSuite in parallel.
type NetlocReplacer ¶
type NetlocReplacer struct {
BaseStringReplacer
}
type NilDataHandler ¶
type NilDataHandler struct{}
type ResponseHandler ¶
type SchemeReplacer ¶
type SchemeReplacer struct {
BaseStringReplacer
}
type StringReplacer ¶
type StringResponseHandler ¶
type StringResponseHandler struct {
BaseResponseHandler
}
func (*StringResponseHandler) Assert ¶
func (s *StringResponseHandler) Assert(c *Case)
type Suite ¶
func NewSuiteFromYAMLFile ¶
type TextDataHandler ¶
type TextDataHandler struct{}
type URLReplacer ¶
type URLReplacer struct {
BaseStringReplacer
}
Click to show internal directories.
Click to hide internal directories.