model

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2023 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 ComparisonString

func ComparisonString(s string) (Comparison, error)

ComparisonString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func ComparisonValues

func ComparisonValues() []Comparison

ComparisonValues returns all values of the enum

func (Comparison) GetMessage

func (i Comparison) GetMessage() comparisonMessage

func (Comparison) IsAComparison

func (i Comparison) IsAComparison() bool

IsAComparison returns "true" if the value is listed in the enum definition. "false" otherwise

func (Comparison) MarshalJSON

func (i Comparison) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for Comparison

func (Comparison) String

func (i Comparison) String() string

func (*Comparison) UnmarshalJSON

func (i *Comparison) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for Comparison

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
)

func ResultVariableTypeString

func ResultVariableTypeString(s string) (ResultVariableType, error)

ResultVariableTypeString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func ResultVariableTypeValues

func ResultVariableTypeValues() []ResultVariableType

ResultVariableTypeValues returns all values of the enum

func (ResultVariableType) IsAResultVariableType

func (i ResultVariableType) IsAResultVariableType() bool

IsAResultVariableType returns "true" if the value is listed in the enum definition. "false" otherwise

func (ResultVariableType) MarshalJSON

func (i ResultVariableType) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for ResultVariableType

func (ResultVariableType) String

func (i ResultVariableType) String() string

func (*ResultVariableType) UnmarshalJSON

func (i *ResultVariableType) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for ResultVariableType

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
)

func SourceString

func SourceString(s string) (Source, error)

SourceString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func SourceValues

func SourceValues() []Source

SourceValues returns all values of the enum

func (Source) IsASource

func (i Source) IsASource() bool

IsASource returns "true" if the value is listed in the enum definition. "false" otherwise

func (Source) MarshalJSON

func (i Source) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for Source

func (Source) String

func (i Source) String() string

func (*Source) UnmarshalJSON

func (i *Source) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for Source

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
)

func StepTypeString

func StepTypeString(s string) (StepType, error)

StepTypeString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func StepTypeValues

func StepTypeValues() []StepType

StepTypeValues returns all values of the enum

func (StepType) IsAStepType

func (i StepType) IsAStepType() bool

IsAStepType returns "true" if the value is listed in the enum definition. "false" otherwise

func (StepType) MarshalJSON

func (i StepType) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for StepType

func (StepType) String

func (i StepType) String() string

func (*StepType) UnmarshalJSON

func (i *StepType) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for StepType

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