1
0
mirror of https://github.com/pocketbase/pocketbase.git synced 2025-01-24 22:32:42 +02:00

[#396] normalized tests.ApiScenario.TestAppFactory declaration

This commit is contained in:
Gani Georgiev 2022-09-07 20:51:03 +03:00
parent 74108d84ca
commit a0d7f23d77

View File

@ -36,7 +36,7 @@ type ApiScenario struct {
// test hooks // test hooks
// --- // ---
TestAppFactory func() *TestApp TestAppFactory func() (*TestApp, error)
BeforeTestFunc func(t *testing.T, app *TestApp, e *echo.Echo) BeforeTestFunc func(t *testing.T, app *TestApp, e *echo.Echo)
AfterTestFunc func(t *testing.T, app *TestApp, e *echo.Echo) AfterTestFunc func(t *testing.T, app *TestApp, e *echo.Echo)
} }
@ -44,13 +44,14 @@ type ApiScenario struct {
// Test executes the test case/scenario. // Test executes the test case/scenario.
func (scenario *ApiScenario) Test(t *testing.T) { func (scenario *ApiScenario) Test(t *testing.T) {
var testApp *TestApp var testApp *TestApp
var testAppErr error
if scenario.TestAppFactory != nil { if scenario.TestAppFactory != nil {
testApp = scenario.TestAppFactory() testApp, testAppErr = scenario.TestAppFactory()
} else { } else {
testApp, _ = NewTestApp() testApp, testAppErr = NewTestApp()
} }
if testApp == nil { if testAppErr != nil {
t.Fatal("Failed to initialize the test app instance.") t.Fatalf("Failed to initialize the test app instance: %v", testAppErr)
} }
defer testApp.Cleanup() defer testApp.Cleanup()