Documentation
¶
Overview ¶
Package runtime analyses runtime output and converts it into assert statements
Index ¶
- func Contains(mem []string, key string) bool
- func EndName(funcName string, index int) string
- func StartName(funcName string, index int) string
- type AssertStmt
- type AssertStmtType
- type AssignStmt
- type AssignStmtType
- type Info
- type Output
- type OutputParser
- func (o *OutputParser) AssertStmts(data *Output, replacements []Replacement, typeCorrection TypeCorrections, ...) []Stmt
- func (o *OutputParser) CreateAssertStmts(runtimeOutput *Output, replacements []Replacement, ...) []Stmt
- func (o *OutputParser) Parse(printed, funcName string, index int) ([]Stmt, bool)
- func (o *OutputParser) ParseLine(jsonString string) []Stmt
- type Replacement
- type Stmt
- type StmtPrinter
- type StmtType
- type TestifySuitePrinter
- type TypeCorrections
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AssertStmt ¶
type AssertStmt struct { AssertStmtType AssertStmtType Expected string Value string }
AssertStmt an assert statement
func (*AssertStmt) Replace ¶
func (a *AssertStmt) Replace(key, val string)
Replace replaces key with value
func (*AssertStmt) Type ¶
func (a *AssertStmt) Type() StmtType
Type retrieves the type of assert stmt
type AssertStmtType ¶
type AssertStmtType string
AssertStmtType Type of assert statement
const ( AssertStmtTypeEqualValues AssertStmtType = "EqualValues" AssertStmtTypeNil AssertStmtType = "Nil" AssertStmtTypeNoError AssertStmtType = "NoError" AssertStmtTypeError AssertStmtType = "Error" AssertStmtTypeFalse AssertStmtType = "False" AssertStmtTypeTrue AssertStmtType = "True" )
Used assert statement types
type AssignStmt ¶
type AssignStmt struct { AssignStmtType AssignStmtType LeftHand string RightHand string }
AssignStmt an assign statement
func (*AssignStmt) Replace ¶
func (a *AssignStmt) Replace(key, val string)
Replace replaces key with value used to resolve map and array index values
func (*AssignStmt) Type ¶
func (a *AssignStmt) Type() StmtType
Type retrieves the type of assert stmt
type AssignStmtType ¶
type AssignStmtType string
AssignStmtType is the type of assign statement
const ( AssignStmtTypeDefine AssignStmtType = ":=" AssignSTmtTypeAssign AssignStmtType = "=" )
Different assign statement types
type Info ¶
type Info struct { Panics bool AssertStmts []Stmt SecondRun []Stmt Printer StmtPrinter }
Info information about values on runtime
func NewInfo ¶
func NewInfo(printer StmtPrinter) *Info
NewInfo creates new runtime info for given printer
func (*Info) AssertStmtsForTestCase ¶
AssertStmtsForTestCase creates assert statements for a testcase
func (*Info) GetAssertStmts ¶
GetAssertStmts retrieve the assert statements
type Output ¶
type Output struct { Type string `json:"type"` VarName string `json:"var_name"` MapKeyType string `json:"map_key_type"` Val string `json:"val"` ArrIdent string `json:"arr_ident"` Child *Output `json:"child"` }
Output JSON structure for runtime output
type OutputParser ¶
type OutputParser struct {
// contains filtered or unexported fields
}
OutputParser parses runtime output strings
func NewOutputParser ¶
func NewOutputParser() *OutputParser
NewOutputParser creates a new output paraser
func (*OutputParser) AssertStmts ¶
func (o *OutputParser) AssertStmts(data *Output, replacements []Replacement, typeCorrection TypeCorrections, resStmts []Stmt) []Stmt
AssertStmts new assert statement from runtime output
func (*OutputParser) CreateAssertStmts ¶
func (o *OutputParser) CreateAssertStmts(runtimeOutput *Output, replacements []Replacement, typeCorrection TypeCorrections, resStmts []Stmt) []Stmt
CreateAssertStmts creates the eventual assert statement based on runtime output and corrections
func (*OutputParser) Parse ¶
func (o *OutputParser) Parse(printed, funcName string, index int) ([]Stmt, bool)
Parse parses printed runtime output to statements
func (*OutputParser) ParseLine ¶
func (o *OutputParser) ParseLine(jsonString string) []Stmt
ParseLine parses a line of output
type Replacement ¶
Replacement struct which contains keys and replacement values
type StmtPrinter ¶
StmtPrinter printer for assert statements
func NewTestifySuitePrinter ¶
func NewTestifySuitePrinter(receiver string) StmtPrinter
NewTestifySuitePrinter new testify suite
type TestifySuitePrinter ¶
type TestifySuitePrinter struct {
Receiver string
}
TestifySuitePrinter printer for testify suites
func (*TestifySuitePrinter) PrintAssertStmt ¶
func (t *TestifySuitePrinter) PrintAssertStmt(astmt *AssertStmt) string
PrintAssertStmt prints an assert statement for a testcase in a testify suite
func (*TestifySuitePrinter) PrintAssignStmt ¶
func (t *TestifySuitePrinter) PrintAssignStmt(astmt *AssignStmt) string
PrintAssignStmt prints an assign stmt
func (*TestifySuitePrinter) PrintStmt ¶
func (t *TestifySuitePrinter) PrintStmt(stmt Stmt) string
PrintStmt prints a statement
func (*TestifySuitePrinter) String ¶
func (t *TestifySuitePrinter) String() string
type TypeCorrections ¶
TypeCorrections struct containing information for printing corrections in types e.g. custom values X(int(3)) in order to make correct assert statements