manatest

package
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2018 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package manatest provides internal workings for go-mana-test.

Package manatest provides internal workings for go-mana-test.

Package manatest provides internal workings for go-mana-test.

Package manatest provides internal workings for go-mana-test.

Package manatest provides internal workings for go-mana-test.

Package manatest provides internal workings for go-mana-test.

Index

Constants

View Source
const (
	CheckResCode     = "response.code"
	CheckResBodyJSON = "response.body.json"
)

Checks.

View Source
const (
	CacheBodyJSON = "response.body.json"
)

Cache.

Variables

This section is empty.

Functions

func ClearCache

func ClearCache()

ClearCache Clears cache.

func GetCache

func GetCache(key string) string

GetCache Gets a value from inside of cache.

func GetCacheKeys

func GetCacheKeys() []string

GetCacheKeys Gets a value from inside of cache.

func ReplaceCache

func ReplaceCache(str string) string

ReplaceCache Replaces cache.

func ReplaceEnvironmentVars added in v0.2.0

func ReplaceEnvironmentVars(str string) string

ReplaceEnvironmentVars Replaces environment variables.

func ReplaceGlobalVars

func ReplaceGlobalVars(str string, vars *[]ProjectGlobal) string

ReplaceGlobalVars Replaces global variables in a string.

func ReplaceRandomNumber

func ReplaceRandomNumber(str string) string

ReplaceRandomNumber Replaces random number.

func ReplaceRandomString

func ReplaceRandomString(str string) string

ReplaceRandomString Replaces random string.

func ReplaceRandomStringLower

func ReplaceRandomStringLower(str string) string

ReplaceRandomStringLower Replaces random string lower.

func ReplaceRandomStringUpper

func ReplaceRandomStringUpper(str string) string

ReplaceRandomStringUpper Replaces random string upper.

func ReplaceVarsInCheck added in v0.2.0

func ReplaceVarsInCheck(str string, vars *[]ProjectGlobal) string

ReplaceVarsInCheck Replaces variables in a test check.

func ReplaceVarsInGlobal added in v0.2.0

func ReplaceVarsInGlobal(str string) string

ReplaceVarsInGlobal Replaces variables in global.

func ReplaceVarsInHeader added in v0.2.0

func ReplaceVarsInHeader(str string, vars *[]ProjectGlobal) string

ReplaceVarsInHeader Replaces variables in a test check.

func ReplaceVarsInRequestBody added in v0.2.0

func ReplaceVarsInRequestBody(str string, vars *[]ProjectGlobal) string

ReplaceVarsInRequestBody Replaces variables in a request body.

func ReplaceVarsInTestURL added in v0.2.0

func ReplaceVarsInTestURL(str string, vars *[]ProjectGlobal) string

ReplaceVarsInTestURL Replaces variables in a test URL.

func RunChecks

func RunChecks(checks *[]TestChecks, vars *[]ProjectGlobal, response *resty.Response) error

RunChecks Runs checks for a test and a project.

func SaveCacheFromResponse

func SaveCacheFromResponse(caches *[]TestCache, response *resty.Response) error

SaveCacheFromResponse Saves cache from response.

func SetCache

func SetCache(key string, value string)

SetCache Sets a value inside of cache.

func ValidateCacheValue

func ValidateCacheValue(value *string) bool

ValidateCacheValue Validates cache value.

func ValidateCheck

func ValidateCheck(check *string) bool

ValidateCheck Validates check.

Types

type ProjectFile

type ProjectFile struct {

	// Name, stores the name of the test.
	Name string `yaml:"name"`

	// Tests, stores the paths to tests.
	Tests string `yaml:"tests"`

	// Globals, stores the global variables.
	Globals []ProjectGlobal `yaml:"globals"`
	// contains filtered or unexported fields
}

ProjectFile is a structure to handle a project file.

func ReadProjectFile

func ReadProjectFile(pathFile string) (*ProjectFile, error)

ReadProjectFile Reads a project file.

func (*ProjectFile) GetFilePath

func (projFile *ProjectFile) GetFilePath() string

GetFilePath Gets the path to the project file.

func (*ProjectFile) GetPath

func (projFile *ProjectFile) GetPath() string

GetPath Gets the path of the project file.

func (*ProjectFile) Validate

func (projFile *ProjectFile) Validate() error

Validate Validates a project file is in proper format.

type ProjectGlobal

type ProjectGlobal struct {

	// Key, hold the key of the variable.
	Key string

	// Value, hold the value of the variable.
	Value string
}

ProjectGlobal is a structure to handle a global variables for a project.

type TestCache

type TestCache struct {

	// Name, hold the name of this check for the test.
	Name string `yaml:"name"`

	// Value, hold the value of the test.
	Value string `yaml:"value"`
}

TestCache is a structure to handle cache for a test.

type TestChecks

type TestChecks struct {

	// Name, hold the name of this check for the test.
	Name string `yaml:"name"`

	// Check, hold the check for the test.
	Check string `yaml:"check"`

	// Value, hold the value of the test.
	Value string `yaml:"value"`
}

TestChecks is a structure to handle checks for a test.

type TestFile

type TestFile struct {

	// Name, stores the name of the test.
	Name string `yaml:"name"`

	// Index, hold the index of this test.
	Index int `yaml:"index"`

	// URL, stores the url of the test.
	URL string `yaml:"url"`

	// Parms, key/val params to be attached to the URL
	Params map[string]string `yaml:"params"`

	// Method, stores the http method of the test.
	RequestMethod string `yaml:"request.method"`

	// Headers, stores the header variables.
	RequestHeaders []TestHeader `yaml:"request.headers"`

	// Body, stores the test http body.
	ReqBody interface{} `yaml:"request.body"`

	// TestChecks, stores the checks variables.
	Checks []TestChecks `yaml:"checks"`

	// Cache, stores the cache variables.
	Cache []TestCache `yaml:"cache"`
	// contains filtered or unexported fields
}

TestFile is a structure to handle an individual test file.

func GatherTestFiles

func GatherTestFiles(pathRead string) ([]TestFile, error)

GatherTestFiles Gathers all test files at a path.

func ReadTestFile

func ReadTestFile(pathFile string) (*TestFile, error)

ReadTestFile Reads a test file.

func (*TestFile) GetFilePath

func (testFile *TestFile) GetFilePath() string

GetFilePath Gets the path to the test file.

func (*TestFile) GetPath

func (testFile *TestFile) GetPath() string

GetPath Gets the path of the test file.

func (*TestFile) MakeTestHeaders added in v0.2.0

func (testFile *TestFile) MakeTestHeaders(projFile *ProjectFile) []TestHeader

MakeTestHeaders Prepares HTTP headers for the test but replacing necessary variables.

func (*TestFile) MakeTestURL added in v0.2.0

func (testFile *TestFile) MakeTestURL(projFile *ProjectFile) string

MakeTestURL Prepares HTTP URL for the test but replacing necessary variables.

func (*TestFile) Validate

func (testFile *TestFile) Validate() error

Validate Validates a test file is in proper format.

type TestHeader

type TestHeader struct {

	// Key, hold the key of the header.
	Key string `yaml:"key"`

	// Value, hold the value of the header.
	Value string `yaml:"value"`
}

TestHeader is a structure to handle headers for a test.

Jump to

Keyboard shortcuts

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