common

module
v0.15.3 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2021 License: Apache-2.0

README

SysEleven common library for infrastructure testing

Documentation goreportcard CI

This module hosts an array of convenience functionality aimed at infrastructure tests.

See docs

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) }

Jump to

Keyboard shortcuts

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