...

Package integration

import "edge-infra.dev/test/framework/integration"
Overview
Index
Examples

Overview ▾

func IsIntegrationTest

func IsIntegrationTest() bool

func Only

func Only(e bool) bool

Only &&s the provided bool with isIntegrationTest to simplify writing logic that checks a bool only during integration test runs.

func ReportTestCases

func ReportTestCases(f *framework.Framework, testPackage *TestPackage)

Process the result of each test case in a TestPackage as though it were a locally-run test

func Skip

func Skip(steps ...framework.Step) framework.Step

Skip wraps the provided framework.Step function (intended to be a skipping function, like k8s.NeedsKustomizeKonfig), only running the skipping function if the test run is an integration test run, e.g.: Skip(k8s.NeedsKustomizeKonfig) will not skip the test if it isn't an integration test run, otherwise will execute k8s.NeedsKustomizeKonfig. Allows writing skippers which only make sense in the context of integration tests without nesting every function in checks for IsIntegrationTest()

Example

Code:

// A test suite which is skipped when it is an integration test run +
// exampleSkipper skips the test
_ = framework.New("skipping-suite").Setup(Skip(exampleSkipper))

func SkipIf

func SkipIf(f *framework.Framework)

SkipIf skips a test if the current test run is an integration test

func SkipIfNot

func SkipIfNot(f *framework.Framework)

SkipIfNot skips a test if the current test run is not an integration test

Example

Code:

// A test suite which is skipped when the test run isn't an integration test
_ = framework.New("skipping-suite").Setup(SkipIfNot)

type JSONTestResultsParser

Parse JSON-formatted test results

type JSONTestResultsParser struct{}

func (JSONTestResultsParser) ParseTestResults

func (p JSONTestResultsParser) ParseTestResults(logs io.Reader, packageName string) (*TestPackage, error)

Convert JSON-formatted test results to TestPackage Go struct

type TestCase

type TestCase struct {
    State    string
    Output   strings.Builder
    Duration *time.Duration
}

type TestEvent

type TestEvent struct {
    Time    *time.Time // encodes as an RFC3339-format string
    Action  string
    Package string
    Test    string
    Elapsed *float64 // seconds
    Output  string
}

type TestPackage

type TestPackage struct {
    Duration    *time.Duration
    State       string
    TestCases   map[string]*TestCase
    PackageName string
}

type TestResultsParser

Interface to parse test results from various data formats into a Go struct

type TestResultsParser interface {
    ParseTestResults(logs io.Reader, packageName string) (*TestPackage, error)
}