utest

package
v0.22.28 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Calculate

func Calculate(op interface{}, rvL ...interface{}) (int, error)

Calculate will to calculate two number by operator

func Concat

func Concat(input ...interface{}) (string, error)

Concat will concat any data as string

func ConcatWithVertical

func ConcatWithVertical(input ...interface{}) (string, error)

ConcatWithVertical will concat any data as string join with '|'

func GetImageResource

func GetImageResource(inputRegion, inputZone interface{}) (string, error)

GetImageResource will return the image id for region and zone

func GetNotEqual

func GetNotEqual(v interface{}, vL ...interface{}) (string, error)

GetNotEqual will return the first item of vL that is not equal to v

func GetRegionImage

func GetRegionImage(input interface{}) (string, error)

GetRegionImage will return the image id for region

func GetTimestamp

func GetTimestamp(input interface{}) (string, error)

GetTimestamp will return the timestamp string

func GetUDPNRegionResource

func GetUDPNRegionResource(input interface{}) (string, error)

GetUDPNRegionResource the vpc id for udpn peer destinition

func GetUUID

func GetUUID() (string, error)

GetUUID will return uuid string

func GetValue

func GetValue(obj interface{}, path string) (interface{}, error)

GetValue will return the value of an object by path

func GetZoneImage

func GetZoneImage(input interface{}) (string, error)

GetZoneImage will return the image id for zone

func SearchValue

func SearchValue(arr interface{}, originKey string, originValue interface{}, destKey string) (interface{}, error)

SearchValue will search key/value in an collection and return the value of destination key

func SetReqValue

func SetReqValue(addr interface{}, field string, values ...interface{}) error

SetReqValue will set value into pointer referenced or slice

Types

type Comparators

type Comparators struct {
	// contains filtered or unexported fields
}

Comparators is a collection of compare functions

func NewComparators

func NewComparators() Comparators

NewComparators will return Comparators

func (*Comparators) Get

func (c *Comparators) Get(name string) CompareFunc

Get will return a comparator function by name

type CompareFunc

type CompareFunc func(interface{}, interface{}) (bool, error)

CompareFunc is the function definition of test comparator without type-system

type TestCase

type TestCase struct {
	Invoker       func() (interface{}, error)
	Validators    []TestValidator
	MaxRetries    int
	RetryInterval time.Duration
	T             *testing.T
}

TestCase is the case definition of test case

func (*TestCase) Run

func (t *TestCase) Run() (interface{}, error)

Run will run the test case with retry

type TestContext

type TestContext struct {
	T *testing.T

	Vars        map[string]interface{}
	Comparators *Comparators
}

TestContext is the fixture of sdk acceptance testing

func NewTestContext

func NewTestContext() TestContext

NewTestContext will return a new TestContext

func (*TestContext) GetVar

func (ctx *TestContext) GetVar(name string) interface{}

GetVar will return the variable of test context

func (*TestContext) Must

func (ctx *TestContext) Must(v interface{}, err error) interface{}

Must will check error is nil and return the value

func (*TestContext) MustString

func (ctx *TestContext) MustString(v string, err error) string

MustString will check error is nil and return the string value

func (*TestContext) NewValidator

func (ctx *TestContext) NewValidator(valuePath string, expected interface{}, comparator string) TestValidator

NewValidator will return new validator to validate value is expected

func (*TestContext) NoError

func (ctx *TestContext) NoError(err error)

NoError will check error is nil

func (*TestContext) SetVar

func (ctx *TestContext) SetVar(name string, value interface{})

SetVar will set the variable of test context

type TestValidator

type TestValidator func(interface{}, error) error

TestValidator is the validator function

Jump to

Keyboard shortcuts

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