parser

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseBool added in v0.0.5

func ParseBool(s string) bool

ParseBool parses stirng representation of boolean to boolean value

func ParseInt added in v0.0.5

func ParseInt(s string) int

ParseInt parsers string respresentation of integer to integer value

func ParseTime added in v0.0.5

func ParseTime(s string) time.Duration

ParseTime parsers time from junit.xml schemas

func PropertyExists added in v0.0.5

func PropertyExists(properties Properties, propertyName string) bool

PropertyExists checks if `propertyName` is in Properties

func UUID added in v0.1.0

func UUID(id uuid.UUID, str string) uuid.UUID

UUID ...

Types

type Error

type Error err

Error ...

func NewError

func NewError() Error

NewError ...

func ParseError added in v0.0.5

func ParseError(xml XMLElement) *Error

ParseError parses <error> element from junit schema

type Failure

type Failure err

Failure ...

func NewFailure

func NewFailure() Failure

NewFailure ...

func ParseFailure added in v0.0.5

func ParseFailure(xml XMLElement) *Failure

ParseFailure parses <failure> element from junit schema

type Parser

type Parser interface {
	Parse(string) TestResults
	IsApplicable(string) bool
	GetName() string
}

Parser ...

type Properties

type Properties map[string]string

Properties maps additional parameters for test suites

func ParseProperties added in v0.0.5

func ParseProperties(xml XMLElement) Properties

ParseProperties maps <properties>

type Result added in v0.3.0

type Result struct {
	TestResults []TestResults `json:"testResults"`
}

Result ...

func NewResult added in v0.3.0

func NewResult() Result

NewResult ...

func (*Result) Combine added in v0.3.0

func (me *Result) Combine(other Result)

Combine test results that are part of result

type SemEnv added in v0.7.0

type SemEnv struct {
	ProjectId string `json:"projectId"`

	PipelineId string `json:"pipelineId"`
	WorkflowId string `json:"workflowId"`

	JobStartedAt string `json:"pipelineStartedAt"`

	JobName string `json:"jobName"`
	JobId   string `json:"jobId"`

	AgentType    string `json:"agentType"`
	AgentOsImage string `json:"agentOsImage"`

	GitRefType string `json:"gitRefType"`
	GitRefName string `json:"gitRefName"`
	GitRefSha  string `json:"gitRefSha"`
}

func NewSemEnv added in v0.7.0

func NewSemEnv() SemEnv

type State

type State string

State indicates state of specific test

const (
	// StatePassed indicates that test was successful
	StatePassed State = "passed"
	// StateError indicates that test errored due to unexpected behaviour when running test i.e. exception
	StateError State = "error"
	// StateFailed indicates that test failed due to invalid test result
	StateFailed State = "failed"
	// StateSkipped indicates that test was skipped
	StateSkipped State = "skipped"
	// StateDisabled indicates that test was disabled
	StateDisabled State = "disabled"
)

type Status added in v0.0.5

type Status string

Status stores information about parsing results

const (
	// StatusSuccess indicates that parsing was successful
	StatusSuccess Status = "success"

	// StatusError indicates that parsing failed due to error
	StatusError Status = "error"
)

type Suite

type Suite struct {
	ID         string     `json:"id"`
	Name       string     `json:"name"`
	IsSkipped  bool       `json:"isSkipped"`
	IsDisabled bool       `json:"isDisabled"`
	Timestamp  string     `json:"timestamp"`
	Hostname   string     `json:"hostname"`
	Package    string     `json:"package"`
	Properties Properties `json:"properties"`
	Summary    Summary    `json:"summary"`
	SystemOut  string     `json:"systemOut"`
	SystemErr  string     `json:"systemErr"`
	Tests      []Test     `json:"tests"`
}

Suite ...

func EnsureSuiteByName added in v0.2.2

func EnsureSuiteByName(suites []Suite, name string) (int, *Suite)

EnsureSuiteByName ...

func NewSuite

func NewSuite() Suite

NewSuite ...

func (*Suite) Aggregate

func (me *Suite) Aggregate()

Aggregate all tests in suite

func (*Suite) AppendTest added in v0.2.2

func (me *Suite) AppendTest(test Test)

AppendTest ...

func (*Suite) Combine added in v0.3.0

func (me *Suite) Combine(other Suite)

Combine ...

func (*Suite) EnsureID added in v0.1.0

func (me *Suite) EnsureID(tr TestResults)

EnsureID ...

type Summary

type Summary struct {
	Total    int           `json:"total"`
	Passed   int           `json:"passed"`
	Skipped  int           `json:"skipped"`
	Error    int           `json:"error"`
	Failed   int           `json:"failed"`
	Disabled int           `json:"disabled"`
	Duration time.Duration `json:"duration"`
}

Summary ...

func (*Summary) Merge added in v0.6.0

func (s *Summary) Merge(withSummary *Summary)

Merge merges two summaries together summing each field

type Test

type Test struct {
	ID        string        `json:"id"`
	File      string        `json:"file"`
	Classname string        `json:"classname"`
	Package   string        `json:"package"`
	Name      string        `json:"name"`
	Duration  time.Duration `json:"duration"`
	State     State         `json:"state"`
	Failure   *Failure      `json:"failure"`
	Error     *Error        `json:"error"`
	SystemOut string        `json:"systemOut"`
	SystemErr string        `json:"systemErr"`
	SemEnv    SemEnv        `json:"semaphoreEnv"`
}

Test ...

func NewTest

func NewTest() Test

NewTest ...

func (*Test) EnsureID added in v0.1.0

func (me *Test) EnsureID(s Suite)

EnsureID ...

type TestResult added in v0.7.0

type TestResult struct {
	TestId   string
	GitSha   string
	Duration time.Duration
	JobId    string
	State    State
}

func (*TestResult) String added in v0.7.0

func (t *TestResult) String() []string

type TestResults

type TestResults struct {
	ID            string  `json:"id"`
	Name          string  `json:"name"`
	Framework     string  `json:"framework"`
	IsDisabled    bool    `json:"isDisabled"`
	Summary       Summary `json:"summary"`
	Status        Status  `json:"status"`
	StatusMessage string  `json:"statusMessage"`
	Suites        []Suite `json:"suites"`
}

TestResults ...

func NewTestResults

func NewTestResults() TestResults

NewTestResults ...

func (*TestResults) Aggregate

func (me *TestResults) Aggregate()

Aggregate all test suite summaries

func (*TestResults) ArrangeSuitesByTestFile added in v0.2.2

func (me *TestResults) ArrangeSuitesByTestFile()

ArrangeSuitesByTestFile ...

func (*TestResults) Combine added in v0.3.0

func (me *TestResults) Combine(other TestResults)

Combine ...

func (*TestResults) EnsureID added in v0.1.0

func (me *TestResults) EnsureID()

EnsureID ...

func (*TestResults) Flatten added in v0.3.1

func (me *TestResults) Flatten()

Flatten makes sure we don't have duplicated suites in test results

func (*TestResults) RegenerateID added in v0.4.3

func (me *TestResults) RegenerateID()

RegenerateID ...

type XMLElement

type XMLElement struct {
	XMLName    xml.Name
	Attributes map[string]string `xml:"-"`
	Children   []XMLElement      `xml:",any"`
	Contents   []byte            `xml:",chardata"`
}

XMLElement ...

func NewXMLElement

func NewXMLElement() XMLElement

NewXMLElement ...

func (*XMLElement) Attr

func (me *XMLElement) Attr(attr string) string

Attr ...

func (*XMLElement) Parse

func (me *XMLElement) Parse(reader *bytes.Reader) error

Parse ...

func (*XMLElement) Tag

func (me *XMLElement) Tag() string

Tag ...

func (*XMLElement) UnmarshalXML

func (me *XMLElement) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML ...

Jump to

Keyboard shortcuts

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