Directories ¶
Path | Synopsis |
---|---|
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) }
|
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) } |
Click to show internal directories.
Click to hide internal directories.