types

package
v0.0.0-...-ef8c4a0 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetBagEntry

func GetBagEntry[T any](bag ReportBag, entry ReportBagEntry, defaultVal T) T

Types

type AssertInvocation

type AssertInvocation interface {
	Invocation
	Expression() *hcl.Attribute
}

type ExecRequestInvocation

type ExecRequestInvocation interface {
	Invocation
	ExecWithResult(ctx RattContext) *RequestExecutionResult
}

type ExecutionLog

type ExecutionLog struct {
	Root *ExecutionLogRecord
	All  []*ExecutionLogRecord
	Head *ExecutionLogRecord
}

func NewExecutionLog

func NewExecutionLog() *ExecutionLog

func (*ExecutionLog) Add

func (l *ExecutionLog) Add(iv Invocation, state InvocationState, bag ReportBag)

type ExecutionLogRecord

type ExecutionLogRecord struct {
	Id       string
	State    InvocationState
	Type     InvocationType
	Bag      ReportBag
	Name     string
	DefRange *hcl.Range
	Children []*ExecutionLogRecord
}

type Invocation

type Invocation interface {
	Name() string
	Type() InvocationType
	DefRange() *hcl.Range
	Exec(ctx RattContext)
}

type InvocationState

type InvocationState = string
const (
	BeginState   InvocationState = "BeginState"
	RunningState InvocationState = "RunningState"
	EndState     InvocationState = "EndState"
	FailedState  InvocationState = "FailedState"
)

type InvocationType

type InvocationType = string
const (
	ForEachStepInvocationType InvocationType = "foreachStep"
	ForEachInvocationType     InvocationType = "foreach"
	TestcaseInvocationType    InvocationType = "testcase"
	RequestInvocationType     InvocationType = "request"
	ScriptInvocationType      InvocationType = "script"
	AssertInvocationType      InvocationType = "assert"
	SetInvocationType         InvocationType = "set"
)

type Printer

type Printer interface {
	Print(log *ExecutionLog, ctx RattContext)
	Flush(log *ExecutionLog, ctx RattContext)
}

type RattContext

type RattContext interface {
	NewChild(name string) RattContext
	Id() string
	RootEvalContext() *hcl.EvalContext
	Reporter() Reporter
	Reader() *hclparse.Parser
	Eval() *hcl.EvalContext
	HttpClient() *http.Client
	Bag() ReportBag
}

type RattModel

type RattModel interface {
	Vars() []VarDeclaration
	Requests() []RequestDeclaration
	Scripts() []ScriptDeclaration

	Invocations() []Invocation

	Run()
	Exec(name string, args map[string]string) *RequestExecutionResult
	MustNoErrors()

	// edit endpoints
	UpsertVar(file string, address string, value string)
}

type ReportBag

type ReportBag = map[ReportBagEntry]interface{}

type ReportBagEntry

type ReportBagEntry = string
const (
	IdBagEntry                   ReportBagEntry = "id"
	ItemsLengthBagEntry          ReportBagEntry = "itemsLength"
	ExpressionBagEntry           ReportBagEntry = "expression"
	DurationBagEntry             ReportBagEntry = "duration"
	SetValueBagEntry             ReportBagEntry = "setValue"
	StatusCodeBagEntry           ReportBagEntry = "statusCode"
	StatusTextBagEntry           ReportBagEntry = "statusText"
	ResponseBodyAsStringBagEntry ReportBagEntry = "responseBodyAsString"
)

type Reporter

type Reporter interface {
	HasErrors() bool
	Error(msg string) Reporter
	ErrorWithRange(msg string, r *hcl.Range) Reporter

	AddDiags(diags hcl.Diagnostics) Reporter

	Invocation(iv Invocation, state InvocationState, ctx RattContext) Reporter

	GetDiagnostics() hcl.Diagnostics
	Flush(ctx RattContext) Reporter
}

type RequestDeclaration

type RequestDeclaration interface {
	GetMethod(ctx RattContext) string
	GetUrl(ctx RattContext) string
	GetContentType(ctx RattContext) (string, bool)
	GetBody(ctx RattContext) ([]byte, bool)
	GetArgs() []RequestDeclarationArg
	GetName() string
	DefRange() *hcl.Range
	GetHeaders() []RequestDeclarationHeader
}

type RequestDeclarationArg

type RequestDeclarationArg interface {
	Name() string
	ReadModel() *hcl.Attribute
}

type RequestDeclarationHeader

type RequestDeclarationHeader interface {
	Name(ctx RattContext) string
	Value(ctx RattContext) string
	ReadModel() *hcl.BodyContent
}

type RequestExecutionResult

type RequestExecutionResult struct {
	ExecTime     time.Duration
	RawHeaders   cty.Value
	Headers      cty.Value
	ResponseBody cty.Value

	Status     string
	StatusCode int

	ContentLength int64
	ContentType   string
}

type RequestInvocation

type RequestInvocation interface {
	Invocation
}

type RequestInvocationArg

type RequestInvocationArg interface {
	Name() string
	DefRange() *hcl.Range
	ReadModel() *hcl.Attribute
}

type ScriptDeclaration

type ScriptDeclaration interface {
	GetName() string
	DefRange() *hcl.Range
	Lang(ctx RattContext) string
	Content(ctx RattContext) string
}

type ScriptExecutionResult

type ScriptExecutionResult struct {
	ExecTime time.Duration
}

type ScriptInvocation

type ScriptInvocation interface {
	Invocation
}

type SetInvocation

type SetInvocation interface {
	Invocation
	Expression() *hcl.Attribute
}

type TestCaseInvocation

type TestCaseInvocation interface {
	Invocation
}

type VarDeclaration

type VarDeclaration interface {
	ReadModel() *hcl.Attribute
	Invocation
}

Jump to

Keyboard shortcuts

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