Skip to content

Commit ccb65c1

Browse files
authored
fix: import regression (#775)
1 parent d81f30e commit ccb65c1

30 files changed

+399
-121
lines changed

internal/README.md

+20-10
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,15 @@ import "github.com/formancehq/ledger/internal"
115115

116116
## Constants
117117

118+
<a name="StateInitializing"></a>
119+
120+
```go
121+
const (
122+
StateInitializing = "initializing"
123+
StateInUse = "in-use"
124+
)
125+
```
126+
118127
<a name="MetaTargetTypeAccount"></a>
119128

120129
```go
@@ -240,7 +249,7 @@ type BalancesByAssetsByAccounts map[string]BalancesByAssets
240249
```
241250

242251
<a name="Configuration"></a>
243-
## type [Configuration](<https://github.com/formancehq/ledger/blob/main/internal/ledger.go#L85-L89>)
252+
## type [Configuration](<https://github.com/formancehq/ledger/blob/main/internal/ledger.go#L92-L96>)
244253

245254

246255

@@ -253,7 +262,7 @@ type Configuration struct {
253262
```
254263

255264
<a name="NewDefaultConfiguration"></a>
256-
### func [NewDefaultConfiguration](<https://github.com/formancehq/ledger/blob/main/internal/ledger.go#L116>)
265+
### func [NewDefaultConfiguration](<https://github.com/formancehq/ledger/blob/main/internal/ledger.go#L123>)
257266

258267
```go
259268
func NewDefaultConfiguration() Configuration
@@ -262,7 +271,7 @@ func NewDefaultConfiguration() Configuration
262271

263272

264273
<a name="Configuration.SetDefaults"></a>
265-
### func \(\*Configuration\) [SetDefaults](<https://github.com/formancehq/ledger/blob/main/internal/ledger.go#L91>)
274+
### func \(\*Configuration\) [SetDefaults](<https://github.com/formancehq/ledger/blob/main/internal/ledger.go#L98>)
266275

267276
```go
268277
func (c *Configuration) SetDefaults()
@@ -271,7 +280,7 @@ func (c *Configuration) SetDefaults()
271280

272281

273282
<a name="Configuration.Validate"></a>
274-
### func \(\*Configuration\) [Validate](<https://github.com/formancehq/ledger/blob/main/internal/ledger.go#L106>)
283+
### func \(\*Configuration\) [Validate](<https://github.com/formancehq/ledger/blob/main/internal/ledger.go#L113>)
275284

276285
```go
277286
func (c *Configuration) Validate() error
@@ -399,7 +408,7 @@ func (e ErrInvalidLedgerName) Is(err error) bool
399408

400409

401410
<a name="Ledger"></a>
402-
## type [Ledger](<https://github.com/formancehq/ledger/blob/main/internal/ledger.go#L13-L20>)
411+
## type [Ledger](<https://github.com/formancehq/ledger/blob/main/internal/ledger.go#L18-L26>)
403412

404413

405414

@@ -411,11 +420,12 @@ type Ledger struct {
411420
ID int `json:"id" bun:"id,type:int,scanonly"`
412421
Name string `json:"name" bun:"name,type:varchar(255),pk"`
413422
AddedAt time.Time `json:"addedAt" bun:"added_at,type:timestamp,nullzero"`
423+
State string `json:"-" bun:"state,type:varchar(255),nullzero"`
414424
}
415425
```
416426

417427
<a name="MustNewWithDefault"></a>
418-
### func [MustNewWithDefault](<https://github.com/formancehq/ledger/blob/main/internal/ledger.go#L61>)
428+
### func [MustNewWithDefault](<https://github.com/formancehq/ledger/blob/main/internal/ledger.go#L68>)
419429

420430
```go
421431
func MustNewWithDefault(name string) Ledger
@@ -424,7 +434,7 @@ func MustNewWithDefault(name string) Ledger
424434

425435

426436
<a name="New"></a>
427-
### func [New](<https://github.com/formancehq/ledger/blob/main/internal/ledger.go#L35>)
437+
### func [New](<https://github.com/formancehq/ledger/blob/main/internal/ledger.go#L41>)
428438

429439
```go
430440
func New(name string, configuration Configuration) (*Ledger, error)
@@ -433,7 +443,7 @@ func New(name string, configuration Configuration) (*Ledger, error)
433443

434444

435445
<a name="NewWithDefaults"></a>
436-
### func [NewWithDefaults](<https://github.com/formancehq/ledger/blob/main/internal/ledger.go#L57>)
446+
### func [NewWithDefaults](<https://github.com/formancehq/ledger/blob/main/internal/ledger.go#L64>)
437447

438448
```go
439449
func NewWithDefaults(name string) (*Ledger, error)
@@ -442,7 +452,7 @@ func NewWithDefaults(name string) (*Ledger, error)
442452

443453

444454
<a name="Ledger.HasFeature"></a>
445-
### func \(Ledger\) [HasFeature](<https://github.com/formancehq/ledger/blob/main/internal/ledger.go#L22>)
455+
### func \(Ledger\) [HasFeature](<https://github.com/formancehq/ledger/blob/main/internal/ledger.go#L28>)
446456

447457
```go
448458
func (l Ledger) HasFeature(feature, value string) bool
@@ -451,7 +461,7 @@ func (l Ledger) HasFeature(feature, value string) bool
451461

452462

453463
<a name="Ledger.WithMetadata"></a>
454-
### func \(Ledger\) [WithMetadata](<https://github.com/formancehq/ledger/blob/main/internal/ledger.go#L30>)
464+
### func \(Ledger\) [WithMetadata](<https://github.com/formancehq/ledger/blob/main/internal/ledger.go#L36>)
455465

456466
```go
457467
func (l Ledger) WithMetadata(m metadata.Metadata) Ledger

internal/api/bulking/bulker.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func (b *Bulker) Run(ctx context.Context, bulk Bulk, result chan BulkElementResu
9898
ctrl := b.ctrl
9999
if bulkOptions.Atomic {
100100
var err error
101-
ctrl, err = ctrl.BeginTX(ctx, nil)
101+
ctrl, _, err = ctrl.BeginTX(ctx, nil)
102102
if err != nil {
103103
return fmt.Errorf("error starting transaction: %s", err)
104104
}

internal/api/bulking/bulker_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"encoding/json"
55
"github.com/formancehq/go-libs/v2/logging"
66
"github.com/formancehq/go-libs/v2/pointer"
7+
"github.com/uptrace/bun"
78
"math/big"
89
"testing"
910

@@ -372,7 +373,7 @@ func TestBulk(t *testing.T) {
372373
expectations: func(mockLedger *LedgerController) {
373374
mockLedger.EXPECT().
374375
BeginTX(gomock.Any(), nil).
375-
Return(mockLedger, nil)
376+
Return(mockLedger, &bun.Tx{}, nil)
376377

377378
mockLedger.EXPECT().
378379
SaveAccountMetadata(gomock.Any(), ledgercontroller.Parameters[ledgercontroller.SaveAccountMetadata]{

internal/api/bulking/mocks_ledger_controller_test.go

+5-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/api/common/mocks_ledger_controller_test.go

+5-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/api/v1/mocks_ledger_controller_test.go

+5-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/api/v2/controllers_bulk_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"github.com/formancehq/go-libs/v2/pointer"
77
"github.com/formancehq/ledger/internal/api/bulking"
8+
"github.com/uptrace/bun"
89
"math/big"
910
"net/http"
1011
"net/http/httptest"
@@ -408,7 +409,7 @@ func TestBulk(t *testing.T) {
408409
expectations: func(mockLedger *LedgerController) {
409410
mockLedger.EXPECT().
410411
BeginTX(gomock.Any(), nil).
411-
Return(mockLedger, nil)
412+
Return(mockLedger, &bun.Tx{}, nil)
412413

413414
mockLedger.EXPECT().
414415
SaveAccountMetadata(gomock.Any(), ledgercontroller.Parameters[ledgercontroller.SaveAccountMetadata]{

internal/api/v2/controllers_ledgers_list_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ func TestListLedgers(t *testing.T) {
107107
if tc.expectedStatusCode == 0 || tc.expectedStatusCode == http.StatusOK {
108108
require.Equal(t, http.StatusOK, rec.Code)
109109
cursor := api.DecodeCursorResponse[ledger.Ledger](t, rec.Body)
110+
for i, data := range cursor.Data {
111+
data.State = ledger.StateInitializing
112+
cursor.Data[i] = data
113+
}
110114

111115
require.Equal(t, tc.returnData, cursor.Data)
112116
} else {

internal/api/v2/mocks_ledger_controller_test.go

+5-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/controller/ledger/controller.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"database/sql"
66
"github.com/formancehq/go-libs/v2/metadata"
77
"github.com/formancehq/ledger/internal/machine/vm"
8+
"github.com/uptrace/bun"
89

910
"github.com/formancehq/go-libs/v2/bun/bunpaginate"
1011
"github.com/formancehq/go-libs/v2/migrations"
@@ -14,7 +15,7 @@ import (
1415
//go:generate mockgen -write_source_comment=false -write_package_comment=false -source controller.go -destination controller_generated_test.go -package ledger . Controller
1516

1617
type Controller interface {
17-
BeginTX(ctx context.Context, options *sql.TxOptions) (Controller, error)
18+
BeginTX(ctx context.Context, options *sql.TxOptions) (Controller, *bun.Tx, error)
1819
Commit(ctx context.Context) error
1920
Rollback(ctx context.Context) error
2021

0 commit comments

Comments
 (0)