test

package
v2.0.0-alpha56 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2024 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const MAX_LINE_LENGTH = 50

Chars PER expected/actual string. Can be changed no problem

Variables

View Source
var Emoji = "\U0001F430" + " Keploy:"

Functions

func AddHttpBodyToMap

func AddHttpBodyToMap(body string, m map[string][]string) error

func ArrayToMap

func ArrayToMap(arr []string) map[string]bool

func CheckStringExist

func CheckStringExist(s string, mp map[string][]string) ([]string, bool)

func CompareHeaders

func CompareHeaders(h1 http.Header, h2 http.Header, res *[]models.HeaderResult, noise map[string][]string) bool

func Contains

func Contains(elems []string, v string) bool

func FilterTcsMocks

func FilterTcsMocks(tc *models.TestCase, m []*models.Mock, logger *zap.Logger) []*models.Mock

Filter the mocks based on req and res timestamp of test

func Flatten

func Flatten(j interface{}) map[string][]string

Flatten takes a map and returns a new one where nested maps are replaced by dot-delimited keys. examples of valid jsons - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#examples

func FlattenHttpResponse

func FlattenHttpResponse(h http.Header, body string) (map[string][]string, error)

func InterfaceToString

func InterfaceToString(val interface{}) string

func LeftJoinNoise

func LeftJoinNoise(globalNoise models.GlobalNoise, tsNoise models.GlobalNoise) models.GlobalNoise

func MapToArray

func MapToArray(mp map[string][]string) []string

func Match

func Match(exp, act string, noise map[string][]string, log *zap.Logger) (string, string, bool, error)

func MatchesAnyRegex

func MatchesAnyRegex(str string, regexArray []string) (bool, string)

func UnmarshallJson

func UnmarshallJson(s string, log *zap.Logger) (interface{}, error)

unmarshallJson returns unmarshalled JSON object.

Types

type DiffsPrinter

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

func NewDiffsPrinter

func NewDiffsPrinter(testCase string) DiffsPrinter

func (*DiffsPrinter) PushBodyDiff

func (d *DiffsPrinter) PushBodyDiff(exp, act string, noise map[string][]string)

func (*DiffsPrinter) PushHeaderDiff

func (d *DiffsPrinter) PushHeaderDiff(exp, act, key string, noise map[string][]string)

func (*DiffsPrinter) PushStatusDiff

func (d *DiffsPrinter) PushStatusDiff(exp, act string)

func (*DiffsPrinter) Render

func (d *DiffsPrinter) Render()

Will display and colorize diffs side-by-side

type FetchTestResultsConfig

type FetchTestResultsConfig struct {
	TestReportFS   platform.TestReportDB
	TestReport     *models.TestReport
	Status         *models.TestRunStatus
	TestSet        string
	Success        *int
	Failure        *int
	Ctx            context.Context
	TestReportPath string
	Path           string
}

type InitialiseRunTestSetReturn

type InitialiseRunTestSetReturn struct {
	Tcs           []*models.TestCase
	ErrChan       chan error
	TestReport    *models.TestReport
	DockerID      bool
	UserIP        string
	InitialStatus models.TestRunStatus
	TcsMocks      []*models.Mock
}

type InitialiseTestReturn

type InitialiseTestReturn struct {
	Sessions                 []string
	TestReportFS             *yaml.TestReport
	Ctx                      context.Context
	AbortStopHooksForcefully bool
	ProxySet                 *proxy.ProxySet
	ExitCmd                  chan bool
	YamlStore                platform.TestCaseDB
	LoadedHooks              *hooks.Hook
	AbortStopHooksInterrupt  chan bool
}

type RunTestSetConfig

type RunTestSetConfig struct {
	TestSet        string
	Path           string
	TestReportPath string
	AppCmd         string
	AppContainer   string
	AppNetwork     string
	Delay          uint64
	BuildDelay     time.Duration
	Pid            uint32
	YamlStore      platform.TestCaseDB
	LoadedHooks    *hooks.Hook
	TestReportFS   platform.TestReportDB
	TestRunChan    chan string
	ApiTimeout     uint64
	Ctx            context.Context
	ServeTest      bool
}

type SimulateRequestConfig

type SimulateRequestConfig struct {
	Tc           *models.TestCase
	LoadedHooks  *hooks.Hook
	AppCmd       string
	UserIP       string
	TestSet      string
	ApiTimeout   uint64
	Success      *int
	Failure      *int
	Status       *models.TestRunStatus
	TestReportFS platform.TestReportDB
	TestReport   *models.TestReport
	Path         string
	DockerID     bool
	NoiseConfig  models.GlobalNoise
}

type TestConfig

type TestConfig struct {
	Path               string
	Proxyport          uint32
	TestReportPath     string
	AppCmd             string
	MongoPassword      string
	AppContainer       string
	AppNetwork         string
	Delay              uint64
	BuildDelay         time.Duration
	PassThroughPorts   []uint
	ApiTimeout         uint64
	WithCoverage       bool
	CoverageReportPath string
	EnableTele         bool
}

type TestOptions

type TestOptions struct {
	MongoPassword      string
	Delay              uint64
	BuildDelay         time.Duration
	PassThroughPorts   []uint
	ApiTimeout         uint64
	Tests              map[string][]string
	AppContainer       string
	AppNetwork         string
	ProxyPort          uint32
	GlobalNoise        models.GlobalNoise
	TestsetNoise       models.TestsetNoise
	WithCoverage       bool
	CoverageReportPath string
}

type Tester

type Tester interface {
	Test(path string, testReportPath string, appCmd string, options TestOptions, enableTele bool) bool
	RunTestSet(testSet, path, testReportPath, appCmd, appContainer, appNetwork string, delay uint64, buildDelay time.Duration, pid uint32, ys platform.TestCaseDB, loadedHook *hooks.Hook, testReportfs platform.TestReportDB, testRunChan chan string, apiTimeout uint64, ctx context.Context, testcases map[string]bool, noiseConfig models.GlobalNoise, serveTest bool) models.TestRunStatus
	InitialiseTest(cfg *TestConfig) (InitialiseTestReturn, error)
	InitialiseRunTestSet(cfg *RunTestSetConfig) InitialiseRunTestSetReturn
	SimulateRequest(cfg *SimulateRequestConfig)
	FetchTestResults(cfg *FetchTestResultsConfig) models.TestRunStatus
}

func NewTester

func NewTester(logger *zap.Logger) Tester

Jump to

Keyboard shortcuts

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