engine: resources: Allow nil helper functions in tests

This reduces some of the boilerplate when writing resource tests.
This commit is contained in:
James Shubin
2019-10-29 04:12:25 -04:00
parent 6b1e038c5c
commit d1c5a736ae

View File

@@ -420,15 +420,20 @@ func TestResources1(t *testing.T) {
},
}
if startup != nil {
t.Logf("test #%d: running startup()", index)
if err := startup(); err != nil {
t.Errorf("test #%d: FAIL", index)
t.Errorf("test #%d: could not startup: %+v", index, err)
}
}
// run init
t.Logf("test #%d: running Init", index)
err = res.Init(init)
defer func() {
if cleanup == nil {
return
}
t.Logf("test #%d: running cleanup()", index)
if err := cleanup(); err != nil {
t.Errorf("test #%d: FAIL", index)
@@ -1247,12 +1252,17 @@ func TestResources2(t *testing.T) {
// t.Logf(fmt.Sprintf("test #%d: ", index)+format, v...)
//}
if startup != nil {
t.Logf("test #%d: running startup()", index)
if err := startup(); err != nil {
t.Errorf("test #%d: FAIL", index)
t.Errorf("test #%d: could not startup: %+v", index, err)
}
}
defer func() {
if cleanup == nil {
return
}
t.Logf("test #%d: running cleanup()", index)
if err := cleanup(); err != nil {
t.Errorf("test #%d: FAIL", index)