Closed
Description
Refactor controller tests
- to AAA form
- split tests into functions
Follow standard template as shown below:
func TestReflectGeoTagInTheStatus(t *testing.T) {
defer cleanup()
init()
//arrange
//act
//assert
}
func TestSomethingElse(t *testing.T) {
defer cleanup()
init()
//arrange
//act
//assert
}
//this will be executed for each test that requires
func cleanup(){
//cleaning env vars, resources etc
}
//this will be executed for each test that requires
func init(){
// init reconcilers, clients etc.. whatever
}
//TestMain is reserved GO func. It says that: this will be executed only once for all tests. Don't use that if we don't need
func TestMain(m testing.M){
//cleaning reasources for all tests i.e. remove cluster, or cloud resources etc...
defer TearDown()
//prepare shared resources for all tests. i.e. create test cluster, queue etc..
InitForAllTests()
t.Main()
}
Activity