mirror of
https://github.com/hanzo-fi/stack.git
synced 2026-10-30 20:34:43 +00:00
39 lines
854 B
Go
39 lines
854 B
Go
package v1_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/formancehq/ledger/internal/storage/systemstore"
|
|
|
|
"github.com/formancehq/ledger/internal/api/backend"
|
|
"go.uber.org/mock/gomock"
|
|
)
|
|
|
|
func newTestingBackend(t *testing.T, expectedSchemaCheck bool) (*backend.MockBackend, *backend.MockLedger) {
|
|
ctrl := gomock.NewController(t)
|
|
mockLedger := backend.NewMockLedger(ctrl)
|
|
backend := backend.NewMockBackend(ctrl)
|
|
backend.
|
|
EXPECT().
|
|
GetLedger(gomock.Any(), gomock.Any()).
|
|
MinTimes(0).
|
|
Return(&systemstore.Ledger{}, nil)
|
|
t.Cleanup(func() {
|
|
ctrl.Finish()
|
|
})
|
|
backend.
|
|
EXPECT().
|
|
GetLedgerEngine(gomock.Any(), gomock.Any()).
|
|
MinTimes(0).
|
|
Return(mockLedger, nil)
|
|
t.Cleanup(func() {
|
|
ctrl.Finish()
|
|
})
|
|
if expectedSchemaCheck {
|
|
mockLedger.EXPECT().
|
|
IsDatabaseUpToDate(gomock.Any()).
|
|
Return(true, nil)
|
|
}
|
|
return backend, mockLedger
|
|
}
|