Documentation ¶
Overview ¶
Package common provides frequently used metaphors to be used in infrastructure tests:
* means to define test suites with common setup and teardown functions * setting up and tearing down test environments * implicit handling of k8s access control * convenience for dealing with http connections and result verification
How to define a test suite:
// define a custom type type SampleTestSuite struct { } // Setup is called once per suite // before running any test func (suite *SampleTestSuite) Setup(t *testing.T) { // suite setup code goes here } // TearDown is called once per suite // after running all the tests func (suite *SampleTestSuite) TearDown(t *testing.T) { // suite teardown code goes here } // individual tests must be prefixed with `InfraTest` func (suite *SampleTestSuite) InfraTestSomething(t *testing.T) { // test code goes here } func (suite *SampleTestSuite) InfraTestSomethingElse(t *testing.T) { // test code goes here } // finally, add the main test function func TestMain(t *testing.T) { s11.RunInfraTests(t, &SampleTestSuite{}) }
How to deal with setup/teardown:
import "code.syseleven.de/syseleven/common" type SampleTestSuite struct { // keep the reference to the teardown // function returned by common.Setup teardown func(t *testing.T) } func (suite *SampleTestSuite) Setup(t *testing.T) { suite.teardown = common.Setup(t) } func (suite *SampleTestSuite) TearDown(t *testing.T) { suite.teardown(t) }
Index ¶
- func ExtractSimplePath(data interface{}, path string) interface{}
- func HTTPDoWithCustomValidation(t *testing.T, url string, validate func(int, string) bool)
- func ProxyURL(t *testing.T, serviceName, portName string) string
- func RunInfraTests(t *testing.T, suite InfraTestSuite)
- func Setup(t *testing.T) func(t *testing.T)
- func UnmarshalJSON(data []byte) (map[string]interface{}, error)
- func WaitUntilServiceAvailable(t *testing.T, serviceName string)
- type HTTPProfile
- type InfraTestSuite
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractSimplePath ¶
func ExtractSimplePath(data interface{}, path string) interface{}
func RunInfraTests ¶
func RunInfraTests(t *testing.T, suite InfraTestSuite)
func UnmarshalJSON ¶
Types ¶
type HTTPProfile ¶
func GetHTTPProfile ¶
func GetHTTPProfile(t *testing.T) *HTTPProfile
Click to show internal directories.
Click to hide internal directories.