Skip to content

Commit

Permalink
[pocketbase#396] normalized tests.ApiScenario.TestAppFactory declaration
Browse files Browse the repository at this point in the history
  • Loading branch information
ganigeorgiev committed Sep 7, 2022
1 parent 74108d8 commit a0d7f23
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions tests/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,22 @@ type ApiScenario struct {

// test hooks
// ---
TestAppFactory func() *TestApp
TestAppFactory func() (*TestApp, error)
BeforeTestFunc func(t *testing.T, app *TestApp, e *echo.Echo)
AfterTestFunc func(t *testing.T, app *TestApp, e *echo.Echo)
}

// Test executes the test case/scenario.
func (scenario *ApiScenario) Test(t *testing.T) {
var testApp *TestApp
var testAppErr error
if scenario.TestAppFactory != nil {
testApp = scenario.TestAppFactory()
testApp, testAppErr = scenario.TestAppFactory()
} else {
testApp, _ = NewTestApp()
testApp, testAppErr = NewTestApp()
}
if testApp == nil {
t.Fatal("Failed to initialize the test app instance.")
if testAppErr != nil {
t.Fatalf("Failed to initialize the test app instance: %v", testAppErr)
}
defer testApp.Cleanup()

Expand Down

0 comments on commit a0d7f23

Please sign in to comment.