model

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2020 License: Unlicense Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Assertion

type Assertion struct {
	Comparison Comparison `json:"comparison"`
	Value      string     `json:"value"`
	Source     Source     `json:"Source"`
	Property   string     `json:"property,omitempty"`
}

An Assertions defines one expected result

type Comparison

type Comparison int
const (
	EqualNumber          Comparison = iota //equal_number
	Equal                                  //equal
	NotEqual                               //not_equal
	IsANumber                              //is_a_number
	IsLessThan                             //is_less_than
	IsLessThanOrEqual                      //is_less_than_or_equals
	IsGreaterThan                          //is_greater_than
	IsGreaterThanOrEqual                   //is_greater_than_or_equal
	Contains                               //contains
	DoesNotContain                         //does_not_contain
	NotEmpty                               //not_empty
	Empty                                  //empty
	IsNull                                 //is_null
	HasValue                               //has_value
	HasKey                                 //has_key
)

func (Comparison) GetMessage

func (i Comparison) GetMessage() comparisonMessage

type Response

type Response struct {
	TimeElapsed time.Duration `json:"time_elapsed,omitempty"` // e.g 1ms
	StatusCode  int           `json:"status_code,omitempty"`  // e.g. 200
	Body        string        `json:"body,omitempty"`         // e.g. {"result: Success"}
	Header      http.Header   `json:"header,omitempty"`       // e.g. map[X-Ratelimit-Limit:[600]]
}

func NewResponse

func NewResponse(restResponse rest.Response, timeElapsed time.Duration) (Response, error)

Create a new responseApi from a rest.Response

type ResultAssertion

type ResultAssertion struct {
	Success  bool   `json:"success"`
	Source   Source `json:"source,omitempty"`
	Property string `json:"property,omitempty"`
	Err      error  `json:"error,omitempty"`
	Message  string `json:"message,omitempty"`
}

func NewResultAssertion

func NewResultAssertion(comparison Comparison, success bool, v ...interface{}) ResultAssertion

func (*ResultAssertion) Print

func (ar *ResultAssertion) Print()

type ResultStep

type ResultStep struct {
	// Common result for every step types
	StepType StepType      `json:"step_type"`
	StepTime time.Duration `json:"step_time,omitempty"`

	// Specific for type request
	Request          rest.Request      `json:"request,omitempty"`
	Response         Response          `json:"response,omitempty"`
	Assertions       []ResultAssertion `json:"assertions,omitempty"`
	VariablesApplied []ResultVariable  `json:"variables_applied,omitempty"`
	VariablesCreated []ResultVariable  `json:"variables_created,omitempty"`
}

func (*ResultStep) IsSuccess

func (step *ResultStep) IsSuccess() bool

IsSuccess check if the step was a success or not.

type ResultVariable

type ResultVariable struct {
	Key      string             `json:"name,omitempty"`
	NewValue string             `json:"value,omitempty"`
	Err      error              `json:"error,omitempty"`
	Type     ResultVariableType `json:"-"`
}

func (*ResultVariable) Print

func (rv *ResultVariable) Print()

type ResultVariableType

type ResultVariableType int
const (
	Created ResultVariableType = iota //Variable
	Used                              //Set
)

type Scenario

type Scenario struct {
	Name        string `json:"name"`
	Version     string `json:"version"`
	ExportedAt  int    `json:"exported_at"`
	Steps       []Step `json:"steps"`
	Description string `json:"description"`
}

func InitScenarioFromFile

func InitScenarioFromFile(inputFile string) (Scenario, error)

InitScenarioFromFile creates a scenario from the input file.

type ScenarioResult

type ScenarioResult struct {
	Name        string       `json:"name,omitempty"`
	Version     string       `json:"version,omitempty"`
	Description string       `json:"description,omitempty"`
	StepResults []ResultStep `json:"step_results,omitempty"`
}

func (*ScenarioResult) IsSuccess

func (scenario *ScenarioResult) IsSuccess() bool

IsSuccess check if the scenario was success.

type Source

type Source int
const (
	ResponseStatus Source = iota //response_status
	ResponseTime                 //response_time
	ResponseJson                 //response_json
	ResponseHeader               //response_header
	ResponseText                 //response_text
	ResponseXml                  //response_xml
)

type Step

type Step struct {
	StepType  StepType   `json:"step_type"`
	URL       string     `json:"Url,omitempty"`
	Variables []Variable `json:"variables,omitempty"`

	Headers    map[string][]string `json:"headers,omitempty"`
	Assertions []Assertion         `json:"assertions,omitempty"`
	Method     string              `json:"method,omitempty"`
	Duration   int                 `json:"duration,omitempty"`
	Body       string              `json:"body,omitempty"`
	Skipped    bool                `json:"skipped,omitempty"`
}

type StepType

type StepType int
const (
	Pause       StepType = iota //pause
	RequestStep                 //request
)

type Variable

type Variable struct {
	Source   Source `json:"Source"`
	Property string `json:"property"`
	Name     string `json:"name"`
}

Jump to

Keyboard shortcuts

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