Skip to content

Commit

Permalink
chore: pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
gfyrag committed Sep 26, 2024
1 parent a8555fe commit ab48b9b
Show file tree
Hide file tree
Showing 31 changed files with 91 additions and 107 deletions.
5 changes: 3 additions & 2 deletions cmd/buckets_upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
package cmd

import (
"io"
"testing"

"github.com/formancehq/go-libs/bun/bunconnect"
"github.com/formancehq/go-libs/logging"
"github.com/formancehq/go-libs/testing/docker"
"github.com/formancehq/go-libs/testing/platform/pgtesting"
"github.com/stretchr/testify/require"
"io"
"testing"
)

func TestBucketsUpgrade(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion internal/api/v1/controllers_transactions_create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ package v1

import (
"encoding/json"
"github.com/formancehq/go-libs/time"
"math/big"
"net/http"
"net/http/httptest"
"net/url"
"testing"

"github.com/formancehq/go-libs/time"

"github.com/formancehq/go-libs/api"
"github.com/formancehq/go-libs/auth"
"github.com/formancehq/go-libs/pointer"
Expand Down
3 changes: 2 additions & 1 deletion internal/api/v2/controllers_transactions_create_test.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package v2

import (
"github.com/formancehq/go-libs/time"
"math/big"
"net/http"
"net/http/httptest"
"net/url"
"testing"

"github.com/formancehq/go-libs/time"

"github.com/formancehq/go-libs/api"
"github.com/formancehq/go-libs/auth"
"github.com/formancehq/go-libs/pointer"
Expand Down
5 changes: 3 additions & 2 deletions internal/ledger.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package ledger

import (
"fmt"
"github.com/formancehq/go-libs/metadata"
"github.com/formancehq/go-libs/time"
"regexp"
"slices"

"github.com/formancehq/go-libs/metadata"
"github.com/formancehq/go-libs/time"
)

const (
Expand Down
3 changes: 2 additions & 1 deletion internal/storage/driver/driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ package driver_test

import (
"fmt"
"testing"

"github.com/formancehq/go-libs/bun/bunconnect"
"github.com/formancehq/go-libs/bun/bundebug"
"github.com/formancehq/go-libs/testing/docker"
"github.com/formancehq/go-libs/testing/platform/pgtesting"
"github.com/formancehq/ledger/internal/storage/driver"
"github.com/uptrace/bun"
"testing"

"github.com/formancehq/go-libs/logging"
"github.com/stretchr/testify/require"
Expand Down
5 changes: 3 additions & 2 deletions internal/storage/ledger/accounts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ package ledger

import (
"context"
"math/big"
"testing"

"github.com/formancehq/go-libs/pointer"
ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger"
"github.com/pkg/errors"
"math/big"
"testing"

"github.com/formancehq/go-libs/time"

Expand Down
5 changes: 3 additions & 2 deletions internal/storage/ledger/balances.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package ledger

import (
"context"
"github.com/formancehq/go-libs/platform/postgres"
"github.com/pkg/errors"
"math/big"
"strings"

"github.com/formancehq/go-libs/platform/postgres"
"github.com/pkg/errors"

"github.com/formancehq/ledger/internal/tracing"

"github.com/formancehq/go-libs/query"
Expand Down
8 changes: 5 additions & 3 deletions internal/storage/ledger/balances_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,21 @@ package ledger

import (
"database/sql"
"math/big"
"testing"

"github.com/formancehq/go-libs/metadata"
"github.com/formancehq/go-libs/time"
ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger"
"math/big"
"testing"

"github.com/formancehq/go-libs/logging"
"github.com/formancehq/go-libs/pointer"

libtime "time"

"github.com/formancehq/go-libs/query"
ledger "github.com/formancehq/ledger/internal"
"github.com/stretchr/testify/require"
libtime "time"
)

func TestBalancesGet(t *testing.T) {
Expand Down
5 changes: 3 additions & 2 deletions internal/storage/ledger/logs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ package ledger
import (
"context"
"database/sql"
"math/big"
"testing"

"github.com/alitto/pond"
ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger"
"github.com/pkg/errors"
"math/big"
"testing"

"github.com/formancehq/go-libs/bun/bunpaginate"
"github.com/formancehq/go-libs/time"
Expand Down
5 changes: 3 additions & 2 deletions internal/storage/ledger/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ package ledger

import (
"database/sql"
"math/big"
"testing"

"github.com/formancehq/go-libs/bun/bunconnect"
"github.com/formancehq/go-libs/bun/bundebug"
"github.com/formancehq/go-libs/testing/docker"
Expand All @@ -12,8 +15,6 @@ import (
"github.com/formancehq/ledger/internal/storage/bucket"
systemstore "github.com/formancehq/ledger/internal/storage/system"
"github.com/google/go-cmp/cmp"
"math/big"
"testing"

"github.com/uptrace/bun/dialect/pgdialect"

Expand Down
38 changes: 2 additions & 36 deletions internal/storage/ledger/moves.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package ledger

import (
"context"
"slices"

. "github.com/formancehq/go-libs/collectionutils"
ledger "github.com/formancehq/ledger/internal"
"math/big"
"slices"

"github.com/formancehq/go-libs/bun/bunpaginate"
"github.com/formancehq/go-libs/platform/postgres"
Expand Down Expand Up @@ -93,40 +93,6 @@ type Move struct {

type Moves []*Move

func (m Moves) volumeUpdates() []AccountsVolumes {

aggregatedVolumes := make(map[string]map[string][]*Move)
for _, move := range m {
if _, ok := aggregatedVolumes[move.Account]; !ok {
aggregatedVolumes[move.Account] = make(map[string][]*Move)
}
aggregatedVolumes[move.Account][move.Asset] = append(aggregatedVolumes[move.Account][move.Asset], move)
}

ret := make([]AccountsVolumes, 0)
for account, movesByAsset := range aggregatedVolumes {
for asset, moves := range movesByAsset {
volumes := ledger.NewEmptyVolumes()
for _, move := range moves {
if move.IsSource {
volumes.Output.Add(volumes.Output, (*big.Int)(move.Amount))
} else {
volumes.Input.Add(volumes.Input, (*big.Int)(move.Amount))
}
}
ret = append(ret, AccountsVolumes{
Ledger: moves[0].Ledger,
Account: account,
Asset: asset,
Input: volumes.Input,
Output: volumes.Output,
})
}
}

return ret
}

func (m Moves) ComputePostCommitEffectiveVolumes() ledger.PostCommitVolumes {
type key struct {
Account string
Expand Down
7 changes: 4 additions & 3 deletions internal/storage/ledger/moves_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ package ledger
import (
"database/sql"
"fmt"
"math/big"
"math/rand"
"testing"

"github.com/alitto/pond"
"github.com/formancehq/go-libs/bun/bunpaginate"
"github.com/formancehq/go-libs/logging"
Expand All @@ -14,9 +18,6 @@ import (
ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger"
"github.com/pkg/errors"
"github.com/stretchr/testify/require"
"math/big"
"math/rand"
"testing"
)

func TestMovesInsert(t *testing.T) {
Expand Down
8 changes: 5 additions & 3 deletions internal/storage/ledger/transactions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import (
"context"
"database/sql"
"fmt"
"math/big"
"testing"

"github.com/formancehq/go-libs/platform/postgres"
ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger"
"github.com/shomali11/xsql"
"math/big"
"testing"

"github.com/formancehq/go-libs/time"

Expand All @@ -19,11 +20,12 @@ import (
"github.com/formancehq/go-libs/logging"
"github.com/formancehq/go-libs/pointer"

libtime "time"

"github.com/formancehq/go-libs/metadata"
"github.com/formancehq/go-libs/query"
ledger "github.com/formancehq/ledger/internal"
"github.com/stretchr/testify/require"
libtime "time"
)

func TestTransactionsGetWithVolumes(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion internal/storage/ledger/volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package ledger
import (
"context"
"fmt"
"github.com/formancehq/go-libs/platform/postgres"
"math/big"

"github.com/formancehq/go-libs/platform/postgres"

"github.com/formancehq/ledger/internal/tracing"

"github.com/formancehq/go-libs/bun/bunpaginate"
Expand Down
7 changes: 4 additions & 3 deletions internal/storage/ledger/volumes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ package ledger

import (
"database/sql"
"github.com/formancehq/go-libs/platform/postgres"
ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger"
"github.com/pkg/errors"
"math/big"
"testing"
libtime "time"

"github.com/formancehq/go-libs/platform/postgres"
ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger"
"github.com/pkg/errors"

"github.com/formancehq/go-libs/time"

"github.com/formancehq/go-libs/logging"
Expand Down
3 changes: 2 additions & 1 deletion internal/storage/system/configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
package system

import (
"testing"

"github.com/formancehq/go-libs/logging"
"github.com/formancehq/go-libs/platform/postgres"
"github.com/stretchr/testify/require"
"testing"
)

func TestConfiguration(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion internal/storage/system/ledgers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ package system

import (
"fmt"
"testing"

"github.com/formancehq/go-libs/bun/bundebug"
"github.com/formancehq/go-libs/metadata"
ledger "github.com/formancehq/ledger/internal"
ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger"
"github.com/uptrace/bun"
"testing"

"github.com/google/uuid"

Expand Down
3 changes: 2 additions & 1 deletion internal/storage/system/migrations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ package system
import (
"context"
"fmt"
"testing"

"github.com/formancehq/go-libs/bun/bunconnect"
"github.com/formancehq/go-libs/bun/bundebug"
"github.com/formancehq/go-libs/logging"
Expand All @@ -13,7 +15,6 @@ import (
ledger "github.com/formancehq/ledger/internal"
"github.com/stretchr/testify/require"
"github.com/uptrace/bun"
"testing"
)

type Hook struct {
Expand Down
3 changes: 2 additions & 1 deletion internal/transaction_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package ledger

import (
"github.com/formancehq/go-libs/time"
"math/big"
"testing"

"github.com/formancehq/go-libs/time"

"github.com/stretchr/testify/require"
)

Expand Down
5 changes: 3 additions & 2 deletions test/e2e/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ package test_suite
import (
"encoding/json"
"fmt"
"io"
"math/big"

"github.com/formancehq/go-libs/logging"
"github.com/formancehq/go-libs/pointer"
. "github.com/formancehq/go-libs/testing/api"
Expand All @@ -15,8 +18,6 @@ import (
"github.com/formancehq/stack/ledger/client/models/operations"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"io"
"math/big"
)

var _ = Context("Ledger integration tests", func() {
Expand Down
Loading

0 comments on commit ab48b9b

Please sign in to comment.