utils

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2022 License: Apache-2.0 Imports: 11 Imported by: 4

Documentation

Index

Constants

View Source
const RUN_STAGE_ENV_VAR = "RUN_STAGE"

Variables

This section is empty.

Functions

func BinaryInPath

func BinaryInPath(bin string) error

BinaryInPath checks if a given binary is in path.

func DeleteFromResult

func DeleteFromResult(t testing.TB, pth string, r gjson.Result) gjson.Result

DeleteFromResult deletes given path from result and returns the modified result

func GetFirstMatchResult

func GetFirstMatchResult(t testing.TB, rs []gjson.Result, k, v string) gjson.Result

GetFirstMatchResult returns the first matching result with a given k/v

func GetLoggerFromT

func GetLoggerFromT() *logger.Logger

GetLoggerFromT returns a logger based on test verbosity

func GetResultStrSlice

func GetResultStrSlice(rs []gjson.Result) []string

GetResultStrSlice parses results into a string slice

func LoadJSON

func LoadJSON(t testing.TB, path string) gjson.Result

LoadJSON reads and parses a json file into a gjson.Result. It fails test if not unable to parse.

func ParseJSONResult

func ParseJSONResult(t testing.TB, j string) gjson.Result

ParseJSONResult converts a JSON string into gjson result

func Poll

func Poll(t testing.TB, condition func() (bool, error), numRetries int, interval time.Duration)

Polls on a particular condition function while the returns true. It fails the test if the condition is not met within numRetries.

func RandStr

func RandStr(l int) string

RandStr generates rand lowercase strings of length l

func RunStage

func RunStage(stageName string, stage func())

RunStage runs stage if stageName matches RUN_STAGE env var or RUN_STAGE is unset. Similar to terratest RunStage but instead of skipping using env var, we match using envvar.

func SetEnv

func SetEnv(t testing.TB, key string, value string)

SetEnv set a environment variable.

func ValFromEnv

func ValFromEnv(t testing.TB, k string) string

ValFromEnv returns value for a given env var. It fails test if not set.

func WriteTmpFile

func WriteTmpFile(data string) (string, error)

WriteTmpFile writes data to a temp file and returns the path.

func WriteTmpFileWithExtension added in v0.2.0

func WriteTmpFileWithExtension(data string, extension string) (string, error)

WriteTmpFileWithExtension writes data to a temp file with given extension and returns the path.

Types

This section is empty.

Jump to

Keyboard shortcuts

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