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:
parent
74108d84ca
commit
a0d7f23d77
11
tests/api.go
11
tests/api.go
@ -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()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user