Documentation ¶
Overview ¶
Package acctest provides a small testing framework for Sherpa
Index ¶
- func BuildBaseTaskGroup(group, task string) *nomad.TaskGroup
- func BuildBaseTestJob(name string) *nomad.Job
- func CheckErrEqual(expected string) func(error) bool
- func CheckJobReachesStatus(s *TestState, status string) error
- func CleanupPurgeJob(s *TestState) error
- func CleanupSherpaPolicy(s *TestState) error
- func IntToPointer(i int) *int
- func StringToPointer(s string) *string
- func Test(t *testing.T, c TestCase)
- type TestCase
- type TestState
- type TestStateFunc
- type TestStep
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildBaseTaskGroup ¶
func BuildBaseTestJob ¶
func CheckErrEqual ¶
CheckErrEqual is a CheckErr func to test if an error message is as expected
func CheckJobReachesStatus ¶
CheckJobReachesStatus performs a check, with a timeout that the test job reaches to desired status.
func CleanupPurgeJob ¶
CleanupPurgeJob is a cleanup func to purge the TestCase job from Nomad
func CleanupSherpaPolicy ¶
CleanupSherpaPolicy is a CleanupFunc to remove a single job policy
func IntToPointer ¶
func StringToPointer ¶
Types ¶
type TestCase ¶
type TestCase struct { // Steps are ran in order stopping on failure Steps []TestStep // CleanupFuncs is called at the end of the TestCase if set CleanupFuncs []TestStateFunc }
TestCase is a single test of Sherpa
type TestState ¶
type TestState struct { // JobName is a concatenation of "sherpa" and the test function name JobName string Sherpa *api.Client Nomad *nomad.Client }
TestState is the configuration for the TestCase
type TestStateFunc ¶
TestStateFunc provides a TestStep with access to the test state
func CheckDeploymentStatus ¶
func CheckDeploymentStatus(status string) TestStateFunc
CheckDeploymentStatus is a TestStateFunc to check if the latest deployment of the TestCase job in Nomad matches the desired status
func CheckTaskGroupCount ¶
func CheckTaskGroupCount(groupName string, count int) TestStateFunc
CheckTaskGroupCount is a TestStateFunc to check a TaskGroup count matches the expected count
func ComposeTestStateFunc ¶
func ComposeTestStateFunc(f ...TestStateFunc) TestStateFunc
ComposeTestStateFunc combines multiple TestStateFuncs into one
type TestStep ¶
type TestStep struct { // Runner is used to execute the step Runner TestStateFunc // ExpectErr allows Runner to fail, use CheckErr to confirm error is correct ExpectErr bool // CheckErr is called if Runner fails and ExpectErr is true CheckErr func(error) bool }
TestStep is a single step within a TestCase