From 9eb8988e7f97554d96711d466e91c46e7ee7c451 Mon Sep 17 00:00:00 2001 From: Geoffrey Ragot Date: Thu, 3 Apr 2025 11:50:37 +0200 Subject: [PATCH 1/4] feat: use test server from go-libs --- go.mod | 96 +++--- go.sum | 185 +++++----- pkg/generate/generator_test.go | 21 +- pkg/testserver/api.go | 52 +-- pkg/testserver/client.go | 12 + pkg/testserver/helpers.go | 48 +-- pkg/testserver/server.go | 337 ++----------------- pkg/testserver/utils.go | 46 +++ pkg/testserver/worker.go | 187 +--------- test/e2e/api_accounts_list_test.go | 12 +- test/e2e/api_accounts_metadata_test.go | 14 +- test/e2e/api_balances_aggregated_test.go | 12 +- test/e2e/api_bulk_test.go | 19 +- test/e2e/api_ledgers_create_test.go | 14 +- test/e2e/api_ledgers_import_test.go | 16 +- test/e2e/api_ledgers_list_test.go | 16 +- test/e2e/api_ledgers_metadata_test.go | 12 +- test/e2e/api_logs_list_test.go | 12 +- test/e2e/api_transactions_create_test.go | 14 +- test/e2e/api_transactions_list_test.go | 12 +- test/e2e/api_transactions_metadata_test.go | 12 +- test/e2e/api_transactions_revert_test.go | 14 +- test/e2e/api_volumes_test.go | 12 +- test/e2e/app_lifecycle_test.go | 59 ++-- test/e2e/app_logs_blocks_async_test.go | 35 +- test/e2e/app_multiple_instance_test.go | 31 +- test/e2e/v1_api_balances_test.go | 14 +- test/performance/pkg/write/local_env_test.go | 2 +- test/stress/stress_test.go | 12 +- tools/generator/go.mod | 30 +- tools/generator/go.sum | 184 +++++----- 31 files changed, 539 insertions(+), 1003 deletions(-) create mode 100644 pkg/testserver/client.go create mode 100644 pkg/testserver/utils.go diff --git a/go.mod b/go.mod index 0f8922c571..83ce70ecfa 100644 --- a/go.mod +++ b/go.mod @@ -1,30 +1,30 @@ module github.com/formancehq/ledger -go 1.23 +go 1.23.0 -toolchain go1.23.2 +toolchain go1.23.3 replace github.com/formancehq/ledger/pkg/client => ./pkg/client replace google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215 => google.golang.org/genproto v0.0.0-20240903143218-8af14fe29dc1 require ( - github.com/ThreeDotsLabs/watermill v1.4.4 + github.com/ThreeDotsLabs/watermill v1.4.6 github.com/alitto/pond v1.9.2 github.com/antlr/antlr4/runtime/Go/antlr v1.4.10 github.com/bluele/gcache v0.0.2 github.com/dop251/goja v0.0.0-20241009100908-5f46f2705ca3 - github.com/formancehq/go-libs/v2 v2.2.3-0.20250401141012-7ef088564530 + github.com/formancehq/go-libs/v2 v2.2.3-0.20250403104105-55a4f9b367d6 github.com/formancehq/ledger/pkg/client v0.0.0-00010101000000-000000000000 github.com/go-chi/chi/v5 v5.2.1 github.com/go-chi/cors v1.2.1 github.com/google/go-cmp v0.7.0 github.com/google/uuid v1.6.0 github.com/invopop/jsonschema v0.13.0 - github.com/jackc/pgx/v5 v5.7.2 + github.com/jackc/pgx/v5 v5.7.4 github.com/jamiealquiza/tachymeter v2.0.0+incompatible github.com/logrusorgru/aurora v2.0.3+incompatible - github.com/nats-io/nats.go v1.39.1 + github.com/nats-io/nats.go v1.40.1 github.com/onsi/ginkgo/v2 v2.22.1 github.com/onsi/gomega v1.36.2 github.com/ory/dockertest/v3 v3.11.0 @@ -35,24 +35,24 @@ require ( github.com/spf13/pflag v1.0.6 github.com/stoewer/go-strcase v1.3.0 github.com/stretchr/testify v1.10.0 - github.com/uptrace/bun v1.2.9 - github.com/uptrace/bun/dialect/pgdialect v1.2.9 + github.com/uptrace/bun v1.2.11 + github.com/uptrace/bun/dialect/pgdialect v1.2.11 github.com/uptrace/bun/extra/bundebug v1.2.9 github.com/xeipuuv/gojsonschema v1.2.0 - github.com/xo/dburl v0.23.3 + github.com/xo/dburl v0.23.4 go.opentelemetry.io/otel v1.35.0 go.opentelemetry.io/otel/metric v1.35.0 go.opentelemetry.io/otel/sdk/metric v1.35.0 go.opentelemetry.io/otel/trace v1.35.0 go.uber.org/fx v1.23.0 go.uber.org/mock v0.5.0 - golang.org/x/oauth2 v0.26.0 - golang.org/x/sync v0.11.0 + golang.org/x/oauth2 v0.28.0 + golang.org/x/sync v0.12.0 ) require ( github.com/robfig/cron/v3 v3.0.1 - github.com/spf13/viper v1.20.0 + github.com/spf13/viper v1.20.1 gopkg.in/yaml.v3 v3.0.1 ) @@ -61,9 +61,9 @@ require ( github.com/hashicorp/go-hclog v1.6.3 // indirect github.com/jackc/pgxlisten v0.0.0-20241106001234-1d6f6656415c // indirect github.com/pelletier/go-toml/v2 v2.2.3 // indirect - github.com/sagikazarmark/locafero v0.7.0 // indirect + github.com/sagikazarmark/locafero v0.9.0 // indirect github.com/sourcegraph/conc v0.3.0 // indirect - github.com/spf13/afero v1.12.0 // indirect + github.com/spf13/afero v1.14.0 // indirect github.com/spf13/cast v1.7.1 // indirect github.com/subosito/gotenv v1.6.0 // indirect go.opentelemetry.io/auto/sdk v1.1.0 // indirect @@ -78,13 +78,13 @@ require ( github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 // indirect github.com/ThreeDotsLabs/watermill-http/v2 v2.3.1 // indirect github.com/ThreeDotsLabs/watermill-kafka/v3 v3.0.6 // indirect - github.com/ThreeDotsLabs/watermill-nats/v2 v2.1.2 // indirect + github.com/ThreeDotsLabs/watermill-nats/v2 v2.1.3 // indirect github.com/ajg/form v1.5.1 // indirect github.com/antlr4-go/antlr/v4 v4.13.1 // indirect github.com/aws/aws-msk-iam-sasl-signer-go v1.0.1 // indirect github.com/aws/aws-sdk-go-v2 v1.36.3 // indirect - github.com/aws/aws-sdk-go-v2/config v1.29.9 // indirect - github.com/aws/aws-sdk-go-v2/credentials v1.17.62 // indirect + github.com/aws/aws-sdk-go-v2/config v1.29.12 // indirect + github.com/aws/aws-sdk-go-v2/credentials v1.17.65 // indirect github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.30 // indirect github.com/aws/aws-sdk-go-v2/feature/rds/auth v1.5.11 // indirect github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.34 // indirect @@ -92,10 +92,10 @@ require ( github.com/aws/aws-sdk-go-v2/internal/ini v1.8.3 // indirect github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.3 // indirect github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.15 // indirect - github.com/aws/aws-sdk-go-v2/service/sso v1.25.1 // indirect - github.com/aws/aws-sdk-go-v2/service/ssooidc v1.29.1 // indirect + github.com/aws/aws-sdk-go-v2/service/sso v1.25.2 // indirect + github.com/aws/aws-sdk-go-v2/service/ssooidc v1.30.0 // indirect github.com/aws/aws-sdk-go-v2/service/sts v1.33.17 // indirect - github.com/aws/smithy-go v1.22.2 // indirect + github.com/aws/smithy-go v1.22.3 // indirect github.com/bahlo/generic-list-go v0.2.0 // indirect github.com/buger/jsonparser v1.1.1 // indirect github.com/cenkalti/backoff/v4 v4.3.0 // indirect @@ -114,24 +114,24 @@ require ( github.com/ericlagergren/decimal v0.0.0-20240411145413-00de7ca16731 // indirect github.com/fatih/color v1.18.0 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect - github.com/formancehq/numscript v0.0.11 + github.com/formancehq/numscript v0.0.15 github.com/go-chi/chi v4.1.2+incompatible // indirect github.com/go-chi/render v1.0.3 // indirect github.com/go-logr/logr v1.4.2 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-ole/go-ole v1.3.0 // indirect github.com/go-sourcemap/sourcemap v2.1.3+incompatible // indirect - github.com/go-sql-driver/mysql v1.9.0 // indirect + github.com/go-sql-driver/mysql v1.9.1 // indirect github.com/go-task/slim-sprig/v3 v3.0.0 // indirect github.com/go-viper/mapstructure/v2 v2.2.1 // indirect github.com/gogo/protobuf v1.3.2 // indirect - github.com/golang/snappy v0.0.4 // indirect + github.com/golang/snappy v1.0.0 // indirect github.com/google/pprof v0.0.0-20241210010833-40e02aabc2ad // indirect github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect github.com/gorilla/mux v1.8.1 // indirect github.com/gorilla/schema v1.4.1 // indirect github.com/gorilla/securecookie v1.1.2 // indirect - github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.1 // indirect + github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect @@ -147,9 +147,9 @@ require ( github.com/jcmturner/gokrb5/v8 v8.4.4 // indirect github.com/jcmturner/rpc/v2 v2.0.3 // indirect github.com/jinzhu/inflection v1.0.0 // indirect - github.com/klauspost/compress v1.17.11 // indirect + github.com/klauspost/compress v1.18.0 // indirect github.com/lithammer/shortuuid/v3 v3.0.7 // indirect - github.com/lufia/plan9stats v0.0.0-20240909124753-873cd0166683 // indirect + github.com/lufia/plan9stats v0.0.0-20250317134145-8bc96cf8fc35 // indirect github.com/mailru/easyjson v0.9.0 // indirect github.com/mattn/go-colorable v0.1.14 // indirect github.com/mattn/go-isatty v0.0.20 // indirect @@ -160,7 +160,7 @@ require ( github.com/muhlemmer/httpforwarded v0.1.0 // indirect github.com/nats-io/jwt/v2 v2.7.3 // indirect github.com/nats-io/nats-server/v2 v2.10.25 // indirect - github.com/nats-io/nkeys v0.4.9 // indirect + github.com/nats-io/nkeys v0.4.10 // indirect github.com/nats-io/nuid v1.0.1 // indirect github.com/oklog/ulid v1.3.1 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect @@ -169,17 +169,17 @@ require ( github.com/pierrec/lz4/v4 v4.1.22 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect - github.com/puzpuzpuz/xsync/v3 v3.5.0 // indirect - github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect + github.com/puzpuzpuz/xsync/v3 v3.5.1 // indirect + github.com/rcrowley/go-metrics v0.0.0-20250401214520-65e299d6c5c9 // indirect github.com/riandyrn/otelchi v0.12.1 // indirect github.com/rs/cors v1.11.1 // indirect - github.com/shirou/gopsutil/v4 v4.24.12 // indirect + github.com/shirou/gopsutil/v4 v4.25.3 // indirect github.com/shomali11/util v0.0.0-20220717175126-f0771b70947f // indirect github.com/sirupsen/logrus v1.9.3 // indirect - github.com/tklauser/go-sysconf v0.3.14 // indirect - github.com/tklauser/numcpus v0.9.0 // indirect + github.com/tklauser/go-sysconf v0.3.15 // indirect + github.com/tklauser/numcpus v0.10.0 // indirect github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc // indirect - github.com/uptrace/bun/extra/bunotel v1.2.9 // indirect + github.com/uptrace/bun/extra/bunotel v1.2.11 // indirect github.com/uptrace/opentelemetry-go-extra/otellogrus v0.3.2 // indirect github.com/uptrace/opentelemetry-go-extra/otelsql v0.3.2 // indirect github.com/uptrace/opentelemetry-go-extra/otelutil v0.3.2 // indirect @@ -193,10 +193,10 @@ require ( github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect github.com/yusufpapurcu/wmi v1.2.4 // indirect github.com/zitadel/oidc/v2 v2.12.2 // indirect - go.opentelemetry.io/contrib/instrumentation/host v0.59.0 // indirect - go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.59.0 // indirect - go.opentelemetry.io/contrib/instrumentation/runtime v0.59.0 // indirect - go.opentelemetry.io/contrib/propagators/b3 v1.34.0 // indirect + go.opentelemetry.io/contrib/instrumentation/host v0.60.0 // indirect + go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.60.0 // indirect + go.opentelemetry.io/contrib/instrumentation/runtime v0.60.0 // indirect + go.opentelemetry.io/contrib/propagators/b3 v1.35.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.35.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.35.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.35.0 // indirect @@ -204,23 +204,23 @@ require ( go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.35.0 // indirect go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v1.35.0 // indirect go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.35.0 // indirect - go.opentelemetry.io/otel/log v0.9.0 // indirect + go.opentelemetry.io/otel/log v0.11.0 // indirect go.opentelemetry.io/otel/sdk v1.35.0 // indirect go.opentelemetry.io/proto/otlp v1.5.0 // indirect go.uber.org/dig v1.18.1 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.0 // indirect - golang.org/x/crypto v0.33.0 // indirect - golang.org/x/exp v0.0.0-20241217172543-b2144cdd0a67 // indirect - golang.org/x/net v0.35.0 // indirect - golang.org/x/sys v0.30.0 // indirect - golang.org/x/text v0.22.0 // indirect + golang.org/x/crypto v0.36.0 // indirect + golang.org/x/exp v0.0.0-20250305212735-054e65f0b394 // indirect + golang.org/x/net v0.38.0 // indirect + golang.org/x/sys v0.31.0 // indirect + golang.org/x/text v0.23.0 // indirect golang.org/x/time v0.9.0 // indirect - golang.org/x/tools v0.30.0 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20250218202821-56aae31c358a // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a // indirect - google.golang.org/grpc v1.71.0 // indirect - google.golang.org/protobuf v1.36.5 // indirect + golang.org/x/tools v0.31.0 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20250324211829-b45e905df463 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20250324211829-b45e905df463 // indirect + google.golang.org/grpc v1.71.1 // indirect + google.golang.org/protobuf v1.36.6 // indirect gopkg.in/go-jose/go-jose.v2 v2.6.3 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect ) diff --git a/go.sum b/go.sum index 025640f1f6..4c9ca11ca5 100644 --- a/go.sum +++ b/go.sum @@ -12,14 +12,14 @@ github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERo github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 h1:TngWCqHvy9oXAN6lEVMRuU21PR1EtLVZJmdB18Gu3Rw= github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8D7ML55dXQrVaamCz2vxCfdQBasLZfHKk= -github.com/ThreeDotsLabs/watermill v1.4.4 h1:aLClMl6EYIOQy4BML9yb2VpTekbynDatvQbXGp7idCU= -github.com/ThreeDotsLabs/watermill v1.4.4/go.mod h1:lBnrLbxOjeMRgcJbv+UiZr8Ylz8RkJ4m6i/VN/Nk+to= +github.com/ThreeDotsLabs/watermill v1.4.6 h1:rWoXlxdBgUyg/bZ3OO0pON+nESVd9r6tnLTgkZ6CYrU= +github.com/ThreeDotsLabs/watermill v1.4.6/go.mod h1:lBnrLbxOjeMRgcJbv+UiZr8Ylz8RkJ4m6i/VN/Nk+to= github.com/ThreeDotsLabs/watermill-http/v2 v2.3.1 h1:M0iYM5HsGcoxtiQqprRlYZNZnGk3w5LsE9RbC2R8myQ= github.com/ThreeDotsLabs/watermill-http/v2 v2.3.1/go.mod h1:RwGHEzGsEEXC/rQNLWQqR83+WPlABgOgnv2kTB56Y4Y= github.com/ThreeDotsLabs/watermill-kafka/v3 v3.0.6 h1:xK+VLDjYvBrRZDaFZ7WSqiNmZ9lcDG5RIilFVDZOVyQ= github.com/ThreeDotsLabs/watermill-kafka/v3 v3.0.6/go.mod h1:o1GcoF/1CSJ9JSmQzUkULvpZeO635pZe+WWrYNFlJNk= -github.com/ThreeDotsLabs/watermill-nats/v2 v2.1.2 h1:9d7Vb2gepq73Rn/aKaAJWbBiJzS6nDyOm4O353jVsTM= -github.com/ThreeDotsLabs/watermill-nats/v2 v2.1.2/go.mod h1:stjbT+s4u/s5ime5jdIyvPyjBGwGeJewIN7jxH8gp4k= +github.com/ThreeDotsLabs/watermill-nats/v2 v2.1.3 h1:/5IfNugBb9H+BvEHHNRnICmF3jaI9P7wVRzA12kDDDs= +github.com/ThreeDotsLabs/watermill-nats/v2 v2.1.3/go.mod h1:stjbT+s4u/s5ime5jdIyvPyjBGwGeJewIN7jxH8gp4k= github.com/ajg/form v1.5.1 h1:t9c7v8JUKu/XxOGBU0yjNpaMloxGEJhUkqFRq0ibGeU= github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY= github.com/alitto/pond v1.9.2 h1:9Qb75z/scEZVCoSU+osVmQ0I0JOeLfdTDafrbcJ8CLs= @@ -32,10 +32,10 @@ github.com/aws/aws-msk-iam-sasl-signer-go v1.0.1 h1:nMp7diZObd4XEVUR0pEvn7/E13JI github.com/aws/aws-msk-iam-sasl-signer-go v1.0.1/go.mod h1:MVYeeOhILFFemC/XlYTClvBjYZrg/EPd3ts885KrNTI= github.com/aws/aws-sdk-go-v2 v1.36.3 h1:mJoei2CxPutQVxaATCzDUjcZEjVRdpsiiXi2o38yqWM= github.com/aws/aws-sdk-go-v2 v1.36.3/go.mod h1:LLXuLpgzEbD766Z5ECcRmi8AzSwfZItDtmABVkRLGzg= -github.com/aws/aws-sdk-go-v2/config v1.29.9 h1:Kg+fAYNaJeGXp1vmjtidss8O2uXIsXwaRqsQJKXVr+0= -github.com/aws/aws-sdk-go-v2/config v1.29.9/go.mod h1:oU3jj2O53kgOU4TXq/yipt6ryiooYjlkqqVaZk7gY/U= -github.com/aws/aws-sdk-go-v2/credentials v1.17.62 h1:fvtQY3zFzYJ9CfixuAQ96IxDrBajbBWGqjNTCa79ocU= -github.com/aws/aws-sdk-go-v2/credentials v1.17.62/go.mod h1:ElETBxIQqcxej++Cs8GyPBbgMys5DgQPTwo7cUPDKt8= +github.com/aws/aws-sdk-go-v2/config v1.29.12 h1:Y/2a+jLPrPbHpFkpAAYkVEtJmxORlXoo5k2g1fa2sUo= +github.com/aws/aws-sdk-go-v2/config v1.29.12/go.mod h1:xse1YTjmORlb/6fhkWi8qJh3cvZi4JoVNhc+NbJt4kI= +github.com/aws/aws-sdk-go-v2/credentials v1.17.65 h1:q+nV2yYegofO/SUXruT+pn4KxkxmaQ++1B/QedcKBFM= +github.com/aws/aws-sdk-go-v2/credentials v1.17.65/go.mod h1:4zyjAuGOdikpNYiSGpsGz8hLGmUzlY8pc8r9QQ/RXYQ= github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.30 h1:x793wxmUWVDhshP8WW2mlnXuFrO4cOd3HLBroh1paFw= github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.30/go.mod h1:Jpne2tDnYiFascUEs2AWHJL9Yp7A5ZVy3TNyxaAjD6M= github.com/aws/aws-sdk-go-v2/feature/rds/auth v1.5.11 h1:qDk85oQdhwP4NR1RpkN+t40aN46/K96hF9J1vDRrkKM= @@ -50,14 +50,14 @@ github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.3 h1:eAh2A4b github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.3/go.mod h1:0yKJC/kb8sAnmlYa6Zs3QVYqaC8ug2AbnNChv5Ox3uA= github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.15 h1:dM9/92u2F1JbDaGooxTq18wmmFzbJRfXfVfy96/1CXM= github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.15/go.mod h1:SwFBy2vjtA0vZbjjaFtfN045boopadnoVPhu4Fv66vY= -github.com/aws/aws-sdk-go-v2/service/sso v1.25.1 h1:8JdC7Gr9NROg1Rusk25IcZeTO59zLxsKgE0gkh5O6h0= -github.com/aws/aws-sdk-go-v2/service/sso v1.25.1/go.mod h1:qs4a9T5EMLl/Cajiw2TcbNt2UNo/Hqlyp+GiuG4CFDI= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.29.1 h1:KwuLovgQPcdjNMfFt9OhUd9a2OwcOKhxfvF4glTzLuA= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.29.1/go.mod h1:MlYRNmYu/fGPoxBQVvBYr9nyr948aY/WLUvwBMBJubs= +github.com/aws/aws-sdk-go-v2/service/sso v1.25.2 h1:pdgODsAhGo4dvzC3JAG5Ce0PX8kWXrTZGx+jxADD+5E= +github.com/aws/aws-sdk-go-v2/service/sso v1.25.2/go.mod h1:qs4a9T5EMLl/Cajiw2TcbNt2UNo/Hqlyp+GiuG4CFDI= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.30.0 h1:90uX0veLKcdHVfvxhkWUQSCi5VabtwMLFutYiRke4oo= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.30.0/go.mod h1:MlYRNmYu/fGPoxBQVvBYr9nyr948aY/WLUvwBMBJubs= github.com/aws/aws-sdk-go-v2/service/sts v1.33.17 h1:PZV5W8yk4OtH1JAuhV2PXwwO9v5G5Aoj+eMCn4T+1Kc= github.com/aws/aws-sdk-go-v2/service/sts v1.33.17/go.mod h1:cQnB8CUnxbMU82JvlqjKR2HBOm3fe9pWorWBza6MBJ4= -github.com/aws/smithy-go v1.22.2 h1:6D9hW43xKFrRx/tXXfAlIZc4JI+yQe6snnWcQyxSyLQ= -github.com/aws/smithy-go v1.22.2/go.mod h1:irrKGvNn1InZwb2d7fkIRNucdfwR8R+Ts3wxYa/cJHg= +github.com/aws/smithy-go v1.22.3 h1:Z//5NuZCSW6R4PhQ93hShNbyBbn8BWCmCVCt+Q8Io5k= +github.com/aws/smithy-go v1.22.3/go.mod h1:t1ufH5HMublsJYulve2RKmHDC15xu1f26kHCp/HgceI= github.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPnH1Wvgk= github.com/bahlo/generic-list-go v0.2.0/go.mod h1:2KvAjgMlE5NNynlg/5iLrrCCZ2+5xWbdbCW3pNTGyYg= github.com/bluele/gcache v0.0.2 h1:WcbfdXICg7G/DGBh1PFfcirkWOQV+v077yF1pSy3DGw= @@ -104,10 +104,10 @@ github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= -github.com/formancehq/go-libs/v2 v2.2.3-0.20250401141012-7ef088564530 h1:c7loJTPm5e/AwayJIWgZZQAqMIBR/BrClfF5aldDlxE= -github.com/formancehq/go-libs/v2 v2.2.3-0.20250401141012-7ef088564530/go.mod h1:JvBjEDWNf7izCy2dq/eI3aMc9d28gChBe1rjw5yYlAs= -github.com/formancehq/numscript v0.0.11 h1:vZDfRfrhOkuInv5fLIXvWZU3ylK+fVgmR4la01dO5to= -github.com/formancehq/numscript v0.0.11/go.mod h1:btuSv05cYwi9BvLRxVs5zrunU+O1vTgigG1T6UsawcY= +github.com/formancehq/go-libs/v2 v2.2.3-0.20250403104105-55a4f9b367d6 h1:JmplOj1BMlJydMvE5ATVE4diLC+Wgt8rivkSEIocU0A= +github.com/formancehq/go-libs/v2 v2.2.3-0.20250403104105-55a4f9b367d6/go.mod h1:to6sgzwqspeTKlAF0Vdj/13EMHc8oYNc2gJfxf7hrt8= +github.com/formancehq/numscript v0.0.15 h1:dprjzbPWWPvIYM1o9P4Ppb6LKs4UuZw3AYeHy78b06k= +github.com/formancehq/numscript v0.0.15/go.mod h1:P8qnq15PyWUuhskZdsrzTTqVS5CBkhakDKEPAyF4oYQ= github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= @@ -138,8 +138,8 @@ github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE= github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78= github.com/go-sourcemap/sourcemap v2.1.3+incompatible h1:W1iEw64niKVGogNgBN3ePyLFfuisuzeidWPMPWmECqU= github.com/go-sourcemap/sourcemap v2.1.3+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg= -github.com/go-sql-driver/mysql v1.9.0 h1:Y0zIbQXhQKmQgTp44Y1dp3wTXcn804QoTptLZT1vtvo= -github.com/go-sql-driver/mysql v1.9.0/go.mod h1:pDetrLJeA3oMujJuvXc8RJoasr589B6A9fwzD3QMrqw= +github.com/go-sql-driver/mysql v1.9.1 h1:FrjNGn/BsJQjVRuSa8CBrM5BWA9BWoXXat3KrtSb/iI= +github.com/go-sql-driver/mysql v1.9.1/go.mod h1:qn46aNg1333BRMNU69Lq93t8du/dwxI64Gl8i5p1WMU= github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= github.com/go-viper/mapstructure/v2 v2.2.1 h1:ZAaOCxANMuZx5RCeg0mBdEZk7DZasvvZIxtHqx8aGss= @@ -150,9 +150,8 @@ github.com/golang/mock v1.7.0-rc.1 h1:YojYx61/OLFsiv6Rw1Z96LpldJIy31o+UHmwAUMJ6/ github.com/golang/mock v1.7.0-rc.1/go.mod h1:s42URUywIqd+OcERslBJvOjepvNymP31m3q8d/GkuRs= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= -github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= -github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/golang/snappy v1.0.0 h1:Oy607GVXHs7RtbggtPBnr2RmDArIsAefDwvrdWvRhGs= +github.com/golang/snappy v1.0.0/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= @@ -173,8 +172,8 @@ github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+ github.com/gorilla/securecookie v1.1.2 h1:YCIWL56dvtr73r6715mJs5ZvhtnY73hBvEF8kXD8ePA= github.com/gorilla/securecookie v1.1.2/go.mod h1:NfCASbcHqRSY+3a8tlWJwsQap2VX5pwzwo4h3eOamfo= github.com/gorilla/sessions v1.2.1/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.1 h1:e9Rjr40Z98/clHv5Yg79Is0NtosR5LXRvdr7o/6NwbA= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.1/go.mod h1:tIxuGz/9mpox++sgp9fJjHO0+q1X9/UOWd798aAm22M= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3 h1:5ZPtiqj0JL5oKWmcsq4VMaAW5ukBEgSGXEN89zeH1Jo= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3/go.mod h1:ndYquD05frm2vACXE1nsccT4oJzjhw2arTS2cpUD1PI= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= @@ -197,8 +196,8 @@ github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsI github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg= github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo= github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM= -github.com/jackc/pgx/v5 v5.7.2 h1:mLoDLV6sonKlvjIEsV56SkWNCnuNv531l94GaIzO+XI= -github.com/jackc/pgx/v5 v5.7.2/go.mod h1:ncY89UGWxg82EykZUwSpUKEfccBGGYq1xjrOpsbsfGQ= +github.com/jackc/pgx/v5 v5.7.4 h1:9wKznZrhWa2QiHL+NjTSPP6yjl3451BX3imWDnokYlg= +github.com/jackc/pgx/v5 v5.7.4/go.mod h1:ncY89UGWxg82EykZUwSpUKEfccBGGYq1xjrOpsbsfGQ= github.com/jackc/pgxlisten v0.0.0-20241106001234-1d6f6656415c h1:bTgmg761ac9Ki27HoLx8IBvc+T+Qj6eptBpKahKIRT4= github.com/jackc/pgxlisten v0.0.0-20241106001234-1d6f6656415c/go.mod h1:N4E1APLOYrbM11HH5kdqAjDa8RJWVwD3JqWpvH22h64= github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo= @@ -223,8 +222,8 @@ github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc= -github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0= +github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo= +github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -235,8 +234,8 @@ github.com/lithammer/shortuuid/v3 v3.0.7 h1:trX0KTHy4Pbwo/6ia8fscyHoGA+mf1jWbPJV github.com/lithammer/shortuuid/v3 v3.0.7/go.mod h1:vMk8ke37EmiewwolSO1NLW8vP4ZaKlRuDIi8tWWmAts= github.com/logrusorgru/aurora v2.0.3+incompatible h1:tOpm7WcpBTn4fjmVfgpQq0EfczGlG91VSDkswnjF5A8= github.com/logrusorgru/aurora v2.0.3+incompatible/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4= -github.com/lufia/plan9stats v0.0.0-20240909124753-873cd0166683 h1:7UMa6KCCMjZEMDtTVdcGu0B1GmmC7QJKiCCjyTAWQy0= -github.com/lufia/plan9stats v0.0.0-20240909124753-873cd0166683/go.mod h1:ilwx/Dta8jXAgpFYFvSWEMwxmbWXyiUHkd5FwyKhb5k= +github.com/lufia/plan9stats v0.0.0-20250317134145-8bc96cf8fc35 h1:PpXWgLPs+Fqr325bN2FD2ISlRRztXibcX6e8f5FR5Dc= +github.com/lufia/plan9stats v0.0.0-20250317134145-8bc96cf8fc35/go.mod h1:autxFIvghDt3jPTLoqZ9OZ7s9qTGNAWmYCjVFWPX/zg= github.com/mailru/easyjson v0.9.0 h1:PrnmzHw7262yW8sTBwxi1PdJA3Iw/EKBa8psRf7d9a4= github.com/mailru/easyjson v0.9.0/go.mod h1:1+xMtQp2MRNVL/V1bOzuP3aP8VNwRW55fQUto+XFtTU= github.com/maruel/natural v1.1.1 h1:Hja7XhhmvEFhcByqDoHz9QZbkWey+COd9xWfCfn1ioo= @@ -263,10 +262,10 @@ github.com/nats-io/jwt/v2 v2.7.3 h1:6bNPK+FXgBeAqdj4cYQ0F8ViHRbi7woQLq4W29nUAzE= github.com/nats-io/jwt/v2 v2.7.3/go.mod h1:GvkcbHhKquj3pkioy5put1wvPxs78UlZ7D/pY+BgZk4= github.com/nats-io/nats-server/v2 v2.10.25 h1:J0GWLDDXo5HId7ti/lTmBfs+lzhmu8RPkoKl0eSCqwc= github.com/nats-io/nats-server/v2 v2.10.25/go.mod h1:/YYYQO7cuoOBt+A7/8cVjuhWTaTUEAlZbJT+3sMAfFU= -github.com/nats-io/nats.go v1.39.1 h1:oTkfKBmz7W047vRxV762M67ZdXeOtUgvbBaNoQ+3PPk= -github.com/nats-io/nats.go v1.39.1/go.mod h1:MgRb8oOdigA6cYpEPhXJuRVH6UE/V4jblJ2jQ27IXYM= -github.com/nats-io/nkeys v0.4.9 h1:qe9Faq2Gxwi6RZnZMXfmGMZkg3afLLOtrU+gDZJ35b0= -github.com/nats-io/nkeys v0.4.9/go.mod h1:jcMqs+FLG+W5YO36OX6wFIFcmpdAns+w1Wm6D3I/evE= +github.com/nats-io/nats.go v1.40.1 h1:MLjDkdsbGUeCMKFyCFoLnNn/HDTqcgVa3EQm+pMNDPk= +github.com/nats-io/nats.go v1.40.1/go.mod h1:wV73x0FSI/orHPSYoyMeJB+KajMDoWyXmFaRrrYaaTo= +github.com/nats-io/nkeys v0.4.10 h1:glmRrpCmYLHByYcePvnTBEAwawwapjCPMjy2huw20wc= +github.com/nats-io/nkeys v0.4.10/go.mod h1:OjRrnIKnWBFl+s4YK5ChQfvHP2fxqZexrKJoVVyWB3U= github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw= github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4= @@ -296,10 +295,10 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRI github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 h1:o4JXh1EVt9k/+g42oCprj/FisM4qX9L3sZB3upGN2ZU= github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE= -github.com/puzpuzpuz/xsync/v3 v3.5.0 h1:i+cMcpEDY1BkNm7lPDkCtE4oElsYLn+EKF8kAu2vXT4= -github.com/puzpuzpuz/xsync/v3 v3.5.0/go.mod h1:VjzYrABPabuM4KyBh1Ftq6u8nhwY5tBPKP9jpmh0nnA= -github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5XpJzTSTfLsJV/mx9Q9g7kxmchpfZyxgzM= -github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= +github.com/puzpuzpuz/xsync/v3 v3.5.1 h1:GJYJZwO6IdxN/IKbneznS6yPkVC+c3zyY/j19c++5Fg= +github.com/puzpuzpuz/xsync/v3 v3.5.1/go.mod h1:VjzYrABPabuM4KyBh1Ftq6u8nhwY5tBPKP9jpmh0nnA= +github.com/rcrowley/go-metrics v0.0.0-20250401214520-65e299d6c5c9 h1:bsUq1dX0N8AOIL7EB/X911+m4EHsnWEHeJ0c+3TTBrg= +github.com/rcrowley/go-metrics v0.0.0-20250401214520-65e299d6c5c9/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/riandyrn/otelchi v0.12.1 h1:FdRKK3/RgZ/T+d+qTH5Uw3MFx0KwRF38SkdfTMMq/m8= github.com/riandyrn/otelchi v0.12.1/go.mod h1:weZZeUJURvtCcbWsdb7Y6F8KFZGedJlSrgUjq9VirV8= github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs= @@ -309,10 +308,10 @@ github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWN github.com/rs/cors v1.11.1 h1:eU3gRzXLRK57F5rKMGMZURNdIG4EoAmX8k94r9wXWHA= github.com/rs/cors v1.11.1/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/sagikazarmark/locafero v0.7.0 h1:5MqpDsTGNDhY8sGp0Aowyf0qKsPrhewaLSsFaodPcyo= -github.com/sagikazarmark/locafero v0.7.0/go.mod h1:2za3Cg5rMaTMoG/2Ulr9AwtFaIppKXTRYnozin4aB5k= -github.com/shirou/gopsutil/v4 v4.24.12 h1:qvePBOk20e0IKA1QXrIIU+jmk+zEiYVVx06WjBRlZo4= -github.com/shirou/gopsutil/v4 v4.24.12/go.mod h1:DCtMPAad2XceTeIAbGyVfycbYQNBGk2P8cvDi7/VN9o= +github.com/sagikazarmark/locafero v0.9.0 h1:GbgQGNtTrEmddYDSAH9QLRyfAHY12md+8YFTqyMTC9k= +github.com/sagikazarmark/locafero v0.9.0/go.mod h1:UBUyz37V+EdMS3hDF3QWIiVr/2dPrx49OMO0Bn0hJqk= +github.com/shirou/gopsutil/v4 v4.25.3 h1:SeA68lsu8gLggyMbmCn8cmp97V1TI9ld9sVzAUcKcKE= +github.com/shirou/gopsutil/v4 v4.25.3/go.mod h1:xbuxyoZj+UsgnZrENu3lQivsngRR5BdjbJwf2fv4szA= github.com/shomali11/parallelizer v0.0.0-20220717173222-a6776fbf40a9/go.mod h1:QsLM53l8gzX0sQbOjVir85bzOUucuJEF8JgE39wD7w0= github.com/shomali11/util v0.0.0-20180607005212-e0f70fd665ff/go.mod h1:WWE2GJM9B5UpdOiwH2val10w/pvJ2cUUQOOA/4LgOng= github.com/shomali11/util v0.0.0-20220717175126-f0771b70947f h1:OM0LVaVycWC+/j5Qra7USyCg2sc+shg3KwygAA+pYvA= @@ -323,16 +322,16 @@ github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo= github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0= -github.com/spf13/afero v1.12.0 h1:UcOPyRBYczmFn6yvphxkn9ZEOY65cpwGKb5mL36mrqs= -github.com/spf13/afero v1.12.0/go.mod h1:ZTlWwG4/ahT8W7T0WQ5uYmjI9duaLQGy3Q2OAl4sk/4= +github.com/spf13/afero v1.14.0 h1:9tH6MapGnn/j0eb0yIXiLjERO8RB6xIVZRDCX7PtqWA= +github.com/spf13/afero v1.14.0/go.mod h1:acJQ8t0ohCGuMN3O+Pv0V0hgMxNYDlvdk+VTfyZmbYo= github.com/spf13/cast v1.7.1 h1:cuNEagBQEHWN1FnbGEjCXL2szYEXqfJPbP2HNUaca9Y= github.com/spf13/cast v1.7.1/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo= github.com/spf13/cobra v1.9.1 h1:CXSaggrXdbHK9CF+8ywj8Amf7PBRmPCOJugH954Nnlo= github.com/spf13/cobra v1.9.1/go.mod h1:nDyEzZ8ogv936Cinf6g1RU9MRY64Ir93oCnqb9wxYW0= github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o= github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= -github.com/spf13/viper v1.20.0 h1:zrxIyR3RQIOsarIrgL8+sAvALXul9jeEPa06Y0Ph6vY= -github.com/spf13/viper v1.20.0/go.mod h1:P9Mdzt1zoHIG8m2eZQinpiBjo6kCmZSKBClNNqjJvu4= +github.com/spf13/viper v1.20.1 h1:ZMi+z/lvLyPSCoNtFCpqjy0S4kPbirhpTMwl8BkW9X4= +github.com/spf13/viper v1.20.1/go.mod h1:P9Mdzt1zoHIG8m2eZQinpiBjo6kCmZSKBClNNqjJvu4= github.com/stoewer/go-strcase v1.3.0 h1:g0eASXYtp+yvN9fK8sH94oCIk0fau9uV1/ZdJ0AVEzs= github.com/stoewer/go-strcase v1.3.0/go.mod h1:fAH5hQ5pehh+j3nZfvwdk2RgEgQjAoM8wodgtPmh1xo= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -358,20 +357,20 @@ github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY= github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28= -github.com/tklauser/go-sysconf v0.3.14 h1:g5vzr9iPFFz24v2KZXs/pvpvh8/V9Fw6vQK5ZZb78yU= -github.com/tklauser/go-sysconf v0.3.14/go.mod h1:1ym4lWMLUOhuBOPGtRcJm7tEGX4SCYNEEEtghGG/8uY= -github.com/tklauser/numcpus v0.9.0 h1:lmyCHtANi8aRUgkckBgoDk1nHCux3n2cgkJLXdQGPDo= -github.com/tklauser/numcpus v0.9.0/go.mod h1:SN6Nq1O3VychhC1npsWostA+oW+VOQTxZrS604NSRyI= +github.com/tklauser/go-sysconf v0.3.15 h1:VE89k0criAymJ/Os65CSn1IXaol+1wrsFHEB8Ol49K4= +github.com/tklauser/go-sysconf v0.3.15/go.mod h1:Dmjwr6tYFIseJw7a3dRLJfsHAMXZ3nEnL/aZY+0IuI4= +github.com/tklauser/numcpus v0.10.0 h1:18njr6LDBk1zuna922MgdjQuJFjrdppsZG60sHGfjso= +github.com/tklauser/numcpus v0.10.0/go.mod h1:BiTKazU708GQTYF4mB+cmlpT2Is1gLk7XVuEeem8LsQ= github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc h1:9lRDQMhESg+zvGYmW5DyG0UqvY96Bu5QYsTLvCHdrgo= github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc/go.mod h1:bciPuU6GHm1iF1pBvUfxfsH0Wmnc2VbpgvbI9ZWuIRs= -github.com/uptrace/bun v1.2.9 h1:OOt2DlIcRUMSZPr6iXDFg/LaQd59kOxbAjpIVHddKRs= -github.com/uptrace/bun v1.2.9/go.mod h1:r2ZaaGs9Ru5bpGTr8GQfp8jp+TlCav9grYCPOu2CJSg= -github.com/uptrace/bun/dialect/pgdialect v1.2.9 h1:caf5uFbOGiXvadV6pA5gn87k0awFFxL1kuuY3SpxnWk= -github.com/uptrace/bun/dialect/pgdialect v1.2.9/go.mod h1:m7L9JtOp/Lt8HccET70ULxplMweE/u0S9lNUSxz2duo= +github.com/uptrace/bun v1.2.11 h1:l9dTymsdZZAoSZ1+Qo3utms0RffgkDbIv+1UGk8N1wQ= +github.com/uptrace/bun v1.2.11/go.mod h1:ww5G8h59UrOnCHmZ8O1I/4Djc7M/Z3E+EWFS2KLB6dQ= +github.com/uptrace/bun/dialect/pgdialect v1.2.11 h1:n0VKWm1fL1dwJK5TRxYYLaRKRe14BOg2+AQgpvqzG/M= +github.com/uptrace/bun/dialect/pgdialect v1.2.11/go.mod h1:NvV1S/zwtwBnW8yhJ3XEKAQEw76SkeH7yUhfrx3W1Eo= github.com/uptrace/bun/extra/bundebug v1.2.9 h1:3SU66p+q76XhfeUUzl9XooVu7hVNueZ/2Q3J8S1uzCU= github.com/uptrace/bun/extra/bundebug v1.2.9/go.mod h1:/rp83jYAtwZUQIz+L3KwvREXaSd5GQGPJUusqq+Qtis= -github.com/uptrace/bun/extra/bunotel v1.2.9 h1:BGGrBga+iVL78SGiMpLt2N9MAKvrG3f8wLk8zCLwFJg= -github.com/uptrace/bun/extra/bunotel v1.2.9/go.mod h1:6dVl5Ko6xOhuoqUPWHpfFrntBDwmOnq0OMiR/SGwAC8= +github.com/uptrace/bun/extra/bunotel v1.2.11 h1:ddt96XrbvlVZu5vBddP6WmbD6bdeJTaWY9jXlfuJKZE= +github.com/uptrace/bun/extra/bunotel v1.2.11/go.mod h1:w6Mhie5tLFeP+5ryjq4PvgZEESRJ1iL2cbvxhm+f8q4= github.com/uptrace/opentelemetry-go-extra/otellogrus v0.3.2 h1:H8wwQwTe5sL6x30z71lUgNiwBdeCHQjrphCfLwqIHGo= github.com/uptrace/opentelemetry-go-extra/otellogrus v0.3.2/go.mod h1:/kR4beFhlz2g+V5ik8jW+3PMiMQAPt29y6K64NNY53c= github.com/uptrace/opentelemetry-go-extra/otelsql v0.3.2 h1:ZjUj9BLYf9PEqBn8W/OapxhPjVRdC6CsXTdULHsyk5c= @@ -397,8 +396,8 @@ github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHo github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74= github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= -github.com/xo/dburl v0.23.3 h1:s9tUyKAkcgRfNQ7ut5gaDWC9s5ROafY3hmNOrGbNXtE= -github.com/xo/dburl v0.23.3/go.mod h1:uazlaAQxj4gkshhfuuYyvwCBouOmNnG2aDxTCFZpmL4= +github.com/xo/dburl v0.23.4 h1:VLI0JT+w95uDiGhCYqbuLTM3gkfg5ODiSoegiEZpcVg= +github.com/xo/dburl v0.23.4/go.mod h1:uazlaAQxj4gkshhfuuYyvwCBouOmNnG2aDxTCFZpmL4= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= @@ -408,14 +407,14 @@ github.com/zitadel/oidc/v2 v2.12.2 h1:3kpckg4rurgw7w7aLJrq7yvRxb2pkNOtD08RH42vPE github.com/zitadel/oidc/v2 v2.12.2/go.mod h1:vhP26g1g4YVntcTi0amMYW3tJuid70nxqxf+kb6XKgg= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= -go.opentelemetry.io/contrib/instrumentation/host v0.59.0 h1:MxVp+9mvrp4FP17hT5BEwMRyk8SDv6kCEq123g5kECE= -go.opentelemetry.io/contrib/instrumentation/host v0.59.0/go.mod h1:5w9UOUSe2M2HMJOWKXX1YjcZIiDbXDu0DkOUQ/nTGS4= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.59.0 h1:CV7UdSGJt/Ao6Gp4CXckLxVRRsRgDHoI8XjbL3PDl8s= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.59.0/go.mod h1:FRmFuRJfag1IZ2dPkHnEoSFVgTVPUd2qf5Vi69hLb8I= -go.opentelemetry.io/contrib/instrumentation/runtime v0.59.0 h1:rfi2MMujBc4yowE0iHckZX4o4jg6SA67EnFVL8ldVvU= -go.opentelemetry.io/contrib/instrumentation/runtime v0.59.0/go.mod h1:IO/gfPEcQYpOpPxn1OXFp1DvRY0viP8ONMedXLjjHIU= -go.opentelemetry.io/contrib/propagators/b3 v1.34.0 h1:9pQdCEvV/6RWQmag94D6rhU+A4rzUhYBEJ8bpscx5p8= -go.opentelemetry.io/contrib/propagators/b3 v1.34.0/go.mod h1:FwM71WS8i1/mAK4n48t0KU6qUS/OZRBgDrHZv3RlJ+w= +go.opentelemetry.io/contrib/instrumentation/host v0.60.0 h1:LD6TMRg2hfNzkMD36Pq0jeYBcSP9W0aJt41Zmje43Ig= +go.opentelemetry.io/contrib/instrumentation/host v0.60.0/go.mod h1:GN4xnih1u2OQeRs8rNJ13XR8XsTqFopc57e/3Kf0h6c= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.60.0 h1:sbiXRNDSWJOTobXh5HyQKjq6wUC5tNybqjIqDpAY4CU= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.60.0/go.mod h1:69uWxva0WgAA/4bu2Yy70SLDBwZXuQ6PbBpbsa5iZrQ= +go.opentelemetry.io/contrib/instrumentation/runtime v0.60.0 h1:0NgN/3SYkqYJ9NBlDfl/2lzVlwos/YQLvi8sUrzJRBE= +go.opentelemetry.io/contrib/instrumentation/runtime v0.60.0/go.mod h1:oxpUfhTkhgQaYIjtBt3T3w135dLoxq//qo3WPlPIKkE= +go.opentelemetry.io/contrib/propagators/b3 v1.35.0 h1:DpwKW04LkdFRFCIgM3sqwTJA/QREHMeMHYPWP1WeaPQ= +go.opentelemetry.io/contrib/propagators/b3 v1.35.0/go.mod h1:9+SNxwqvCWo1qQwUpACBY5YKNVxFJn5mlbXg/4+uKBg= go.opentelemetry.io/otel v1.35.0 h1:xKWKPxrxB6OtMCbmMY021CqC45J+3Onta9MqjhnusiQ= go.opentelemetry.io/otel v1.35.0/go.mod h1:UEqy8Zp11hpkUrL73gSlELM0DupHoiq72dR+Zqel/+Y= go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.35.0 h1:QcFwRrZLc82r8wODjvyCbP7Ifp3UANaBSmhDSFjnqSc= @@ -432,8 +431,8 @@ go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v1.35.0 h1:PB3Zrjs1sG1GBX go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v1.35.0/go.mod h1:U2R3XyVPzn0WX7wOIypPuptulsMcPDPs/oiSVOMVnHY= go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.35.0 h1:T0Ec2E+3YZf5bgTNQVet8iTDW7oIk03tXHq+wkwIDnE= go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.35.0/go.mod h1:30v2gqH+vYGJsesLWFov8u47EpYTcIQcBjKpI6pJThg= -go.opentelemetry.io/otel/log v0.9.0 h1:0OiWRefqJ2QszpCiqwGO0u9ajMPe17q6IscQvvp3czY= -go.opentelemetry.io/otel/log v0.9.0/go.mod h1:WPP4OJ+RBkQ416jrFCQFuFKtXKD6mOoYCQm6ykK8VaU= +go.opentelemetry.io/otel/log v0.11.0 h1:c24Hrlk5WJ8JWcwbQxdBqxZdOK7PcP/LFtOtwpDTe3Y= +go.opentelemetry.io/otel/log v0.11.0/go.mod h1:U/sxQ83FPmT29trrifhQg+Zj2lo1/IPN1PF6RTFqdwc= go.opentelemetry.io/otel/metric v1.35.0 h1:0znxYu2SNyuMSQT4Y9WDWej0VpcsxkuklLa4/siN90M= go.opentelemetry.io/otel/metric v1.35.0/go.mod h1:nKVFgxBZ2fReX6IlyW28MgZojkoAkJGaE8CpgeAU3oE= go.opentelemetry.io/otel/sdk v1.35.0 h1:iPctf8iprVySXSKJffSS79eOjl9pvxV9ZqOWT0QejKY= @@ -461,10 +460,10 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= -golang.org/x/crypto v0.33.0 h1:IOBPskki6Lysi0lo9qQvbxiQ+FvsCC/YWOecCHAixus= -golang.org/x/crypto v0.33.0/go.mod h1:bVdXmD7IV/4GdElGPozy6U7lWdRXA4qyRVGJV57uQ5M= -golang.org/x/exp v0.0.0-20241217172543-b2144cdd0a67 h1:1UoZQm6f0P/ZO0w1Ri+f+ifG/gXhegadRdwBIXEFWDo= -golang.org/x/exp v0.0.0-20241217172543-b2144cdd0a67/go.mod h1:qj5a5QZpwLU2NLQudwIN5koi3beDhSAlJwa67PuM98c= +golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34= +golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc= +golang.org/x/exp v0.0.0-20250305212735-054e65f0b394 h1:nDVHiLt8aIbd/VzvPWN6kSOPE7+F/fNFDSXLVYkE/Iw= +golang.org/x/exp v0.0.0-20250305212735-054e65f0b394/go.mod h1:sIifuuw/Yco/y6yb6+bDNfyeQ/MdPUy/hKEMYQV17cM= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= @@ -477,16 +476,16 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.35.0 h1:T5GQRQb2y08kTAByq9L4/bz8cipCdA8FbRTXewonqY8= -golang.org/x/net v0.35.0/go.mod h1:EglIi67kWsHKlRzzVMUD93VMSWGFOMSZgxFjparz1Qk= -golang.org/x/oauth2 v0.26.0 h1:afQXWNNaeC4nvZ0Ed9XvCCzXM6UHJG7iCg0W4fPqSBE= -golang.org/x/oauth2 v0.26.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= +golang.org/x/net v0.38.0 h1:vRMAPTMaeGqVhG5QyLJHqNDwecKTomGeqbnfZyKlBI8= +golang.org/x/net v0.38.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8= +golang.org/x/oauth2 v0.28.0 h1:CrgCKl8PPAVtLnU3c+EDw6x11699EWlsDeWNWKdIOkc= +golang.org/x/oauth2 v0.28.0/go.mod h1:onh5ek6nERTohokkhCD/y2cV4Do3fxFHFuAejCkRWT8= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w= -golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.12.0 h1:MHc5BpPuC30uJk597Ri8TV3CNZcTLu6B6z4lJy+g6Jw= +golang.org/x/sync v0.12.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -507,8 +506,8 @@ golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc= -golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik= +golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= @@ -517,8 +516,8 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM= -golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY= +golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY= +golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4= golang.org/x/time v0.9.0 h1:EsRrnYcQiGH+5FfbgvV4AP7qEZstoyrHB0DzarOQ4ZY= golang.org/x/time v0.9.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -526,20 +525,20 @@ golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.30.0 h1:BgcpHewrV5AUp2G9MebG4XPFI1E2W41zU1SaqVA9vJY= -golang.org/x/tools v0.30.0/go.mod h1:c347cR/OJfw5TI+GfX7RUPNMdDRRbjvYTS0jPyvsVtY= +golang.org/x/tools v0.31.0 h1:0EedkvKDbh+qistFTd0Bcwe/YLh4vHwWEkiI0toFIBU= +golang.org/x/tools v0.31.0/go.mod h1:naFTU+Cev749tSJRXJlna0T3WxKvb1kWEx15xA4SdmQ= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/genproto/googleapis/api v0.0.0-20250218202821-56aae31c358a h1:nwKuGPlUAt+aR+pcrkfFRrTU1BVrSmYyYMxYbUIVHr0= -google.golang.org/genproto/googleapis/api v0.0.0-20250218202821-56aae31c358a/go.mod h1:3kWAYMk1I75K4vykHtKt2ycnOgpA6974V7bREqbsenU= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a h1:51aaUVRocpvUOSQKM6Q7VuoaktNIaMCLuhZB6DKksq4= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a/go.mod h1:uRxBH1mhmO8PGhU89cMcHaXKZqO+OfakD8QQO0oYwlQ= -google.golang.org/grpc v1.71.0 h1:kF77BGdPTQ4/JZWMlb9VpJ5pa25aqvVqogsxNHHdeBg= -google.golang.org/grpc v1.71.0/go.mod h1:H0GRtasmQOh9LkFoCPDu3ZrwUtD1YGE+b2vYBYd/8Ec= -google.golang.org/protobuf v1.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwlM= -google.golang.org/protobuf v1.36.5/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= +google.golang.org/genproto/googleapis/api v0.0.0-20250324211829-b45e905df463 h1:hE3bRWtU6uceqlh4fhrSnUyjKHMKB9KrTLLG+bc0ddM= +google.golang.org/genproto/googleapis/api v0.0.0-20250324211829-b45e905df463/go.mod h1:U90ffi8eUL9MwPcrJylN5+Mk2v3vuPDptd5yyNUiRR8= +google.golang.org/genproto/googleapis/rpc v0.0.0-20250324211829-b45e905df463 h1:e0AIkUUhxyBKh6ssZNrAMeqhA7RKUj42346d1y02i2g= +google.golang.org/genproto/googleapis/rpc v0.0.0-20250324211829-b45e905df463/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= +google.golang.org/grpc v1.71.1 h1:ffsFWr7ygTUscGPI0KKK6TLrGz0476KUvvsbqWK0rPI= +google.golang.org/grpc v1.71.1/go.mod h1:H0GRtasmQOh9LkFoCPDu3ZrwUtD1YGE+b2vYBYd/8Ec= +google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY= +google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= diff --git a/pkg/generate/generator_test.go b/pkg/generate/generator_test.go index 078d1ee152..20e6c53493 100644 --- a/pkg/generate/generator_test.go +++ b/pkg/generate/generator_test.go @@ -7,6 +7,7 @@ import ( "github.com/formancehq/go-libs/v2/logging" "github.com/formancehq/go-libs/v2/testing/docker" "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" + "github.com/formancehq/go-libs/v2/testing/testservice" "github.com/formancehq/ledger/pkg/client/models/operations" . "github.com/formancehq/ledger/pkg/testserver" "github.com/stretchr/testify/require" @@ -20,20 +21,22 @@ func TestGenerator(t *testing.T) { pgServer := pgtesting.CreatePostgresServer(t, dockerPool) ctx := logging.TestingContext() - testServer := New(t, Configuration{ - CommonConfiguration: CommonConfiguration{ - PostgresConfiguration: bunconnect.ConnectionOptions{ - DatabaseSourceName: pgServer.GetDSN(), - }, + testServer := NewTestServer(testservice.Configuration[ServeConfiguration]{ + CommonConfiguration: testservice.CommonConfiguration{ Debug: os.Getenv("DEBUG") == "true", }, - }) - require.NoError(t, testServer.Start()) + Configuration: ServeConfiguration{ + PostgresConfiguration: PostgresConfiguration(bunconnect.ConnectionOptions{ + DatabaseSourceName: pgServer.GetDSN(), + }), + }, + }, testservice.WithLogger(t)) + require.NoError(t, testServer.Start(ctx)) t.Cleanup(func() { require.NoError(t, testServer.Stop(ctx)) }) - _, err := testServer.Client().Ledger.V2.CreateLedger(ctx, operations.V2CreateLedgerRequest{ + _, err := Client(testServer).Ledger.V2.CreateLedger(ctx, operations.V2CreateLedgerRequest{ Ledger: "default", }) require.NoError(t, err) @@ -49,7 +52,7 @@ func TestGenerator(t *testing.T) { action, err := generator.Next(i) require.NoError(t, err) - _, err = action.Apply(ctx, testServer.Client().Ledger.V2, ledgerName) + _, err = action.Apply(ctx, Client(testServer).Ledger.V2, ledgerName) require.NoError(t, err) } diff --git a/pkg/testserver/api.go b/pkg/testserver/api.go index 935f33df30..dd117fc47c 100644 --- a/pkg/testserver/api.go +++ b/pkg/testserver/api.go @@ -14,12 +14,12 @@ import ( ) func CreateLedger(ctx context.Context, srv *Server, request operations.V2CreateLedgerRequest) error { - _, err := srv.Client().Ledger.V2.CreateLedger(ctx, request) + _, err := Client(srv).Ledger.V2.CreateLedger(ctx, request) return mapSDKError(err) } func GetLedger(ctx context.Context, srv *Server, request operations.V2GetLedgerRequest) (*components.V2Ledger, error) { - ret, err := srv.Client().Ledger.V2.GetLedger(ctx, request) + ret, err := Client(srv).Ledger.V2.GetLedger(ctx, request) if err := mapSDKError(err); err != nil { return nil, err } @@ -27,15 +27,15 @@ func GetLedger(ctx context.Context, srv *Server, request operations.V2GetLedgerR } func GetInfo(ctx context.Context, srv *Server) (*operations.V2GetInfoResponse, error) { - return srv.Client().Ledger.GetInfo(ctx) + return Client(srv).Ledger.GetInfo(ctx) } func GetLedgerInfo(ctx context.Context, srv *Server, request operations.V2GetLedgerInfoRequest) (*operations.V2GetLedgerInfoResponse, error) { - return srv.Client().Ledger.V2.GetLedgerInfo(ctx, request) + return Client(srv).Ledger.V2.GetLedgerInfo(ctx, request) } func CreateTransaction(ctx context.Context, srv *Server, request operations.V2CreateTransactionRequest) (*components.V2Transaction, error) { - response, err := srv.Client().Ledger.V2.CreateTransaction(ctx, request) + response, err := Client(srv).Ledger.V2.CreateTransaction(ctx, request) if err != nil { return nil, mapSDKError(err) @@ -45,7 +45,7 @@ func CreateTransaction(ctx context.Context, srv *Server, request operations.V2Cr } func CreateBulk(ctx context.Context, srv *Server, request operations.V2CreateBulkRequest) ([]components.V2BulkElementResult, error) { - response, err := srv.Client().Ledger.V2.CreateBulk(ctx, request) + response, err := Client(srv).Ledger.V2.CreateBulk(ctx, request) if err != nil { return nil, mapSDKError(err) } @@ -53,7 +53,7 @@ func CreateBulk(ctx context.Context, srv *Server, request operations.V2CreateBul } func GetBalancesAggregated(ctx context.Context, srv *Server, request operations.V2GetBalancesAggregatedRequest) (map[string]*big.Int, error) { - response, err := srv.Client().Ledger.V2.GetBalancesAggregated(ctx, request) + response, err := Client(srv).Ledger.V2.GetBalancesAggregated(ctx, request) if err != nil { return nil, mapSDKError(err) } @@ -61,7 +61,7 @@ func GetBalancesAggregated(ctx context.Context, srv *Server, request operations. } func GetVolumesWithBalances(ctx context.Context, srv *Server, request operations.V2GetVolumesWithBalancesRequest) (*components.V2VolumesWithBalanceCursorResponseCursor, error) { - response, err := srv.Client().Ledger.V2.GetVolumesWithBalances(ctx, request) + response, err := Client(srv).Ledger.V2.GetVolumesWithBalances(ctx, request) if err != nil { return nil, mapSDKError(err) } @@ -69,37 +69,37 @@ func GetVolumesWithBalances(ctx context.Context, srv *Server, request operations } func UpdateLedgerMetadata(ctx context.Context, srv *Server, request operations.V2UpdateLedgerMetadataRequest) error { - _, err := srv.Client().Ledger.V2.UpdateLedgerMetadata(ctx, request) + _, err := Client(srv).Ledger.V2.UpdateLedgerMetadata(ctx, request) return mapSDKError(err) } func DeleteLedgerMetadata(ctx context.Context, srv *Server, request operations.V2DeleteLedgerMetadataRequest) error { - _, err := srv.Client().Ledger.V2.DeleteLedgerMetadata(ctx, request) + _, err := Client(srv).Ledger.V2.DeleteLedgerMetadata(ctx, request) return mapSDKError(err) } func AddMetadataToAccount(ctx context.Context, srv *Server, request operations.V2AddMetadataToAccountRequest) error { - _, err := srv.Client().Ledger.V2.AddMetadataToAccount(ctx, request) + _, err := Client(srv).Ledger.V2.AddMetadataToAccount(ctx, request) return mapSDKError(err) } func AddMetadataToTransaction(ctx context.Context, srv *Server, request operations.V2AddMetadataOnTransactionRequest) error { - _, err := srv.Client().Ledger.V2.AddMetadataOnTransaction(ctx, request) + _, err := Client(srv).Ledger.V2.AddMetadataOnTransaction(ctx, request) return mapSDKError(err) } func DeleteAccountMetadata(ctx context.Context, srv *Server, request operations.V2DeleteAccountMetadataRequest) error { - _, err := srv.Client().Ledger.V2.DeleteAccountMetadata(ctx, request) + _, err := Client(srv).Ledger.V2.DeleteAccountMetadata(ctx, request) return mapSDKError(err) } func DeleteTransactionMetadata(ctx context.Context, srv *Server, request operations.V2DeleteTransactionMetadataRequest) error { - _, err := srv.Client().Ledger.V2.DeleteTransactionMetadata(ctx, request) + _, err := Client(srv).Ledger.V2.DeleteTransactionMetadata(ctx, request) return mapSDKError(err) } func RevertTransaction(ctx context.Context, srv *Server, request operations.V2RevertTransactionRequest) (*components.V2Transaction, error) { - response, err := srv.Client().Ledger.V2.RevertTransaction(ctx, request) + response, err := Client(srv).Ledger.V2.RevertTransaction(ctx, request) if err != nil { return nil, mapSDKError(err) @@ -109,7 +109,7 @@ func RevertTransaction(ctx context.Context, srv *Server, request operations.V2Re } func GetTransaction(ctx context.Context, srv *Server, request operations.V2GetTransactionRequest) (*components.V2Transaction, error) { - response, err := srv.Client().Ledger.V2.GetTransaction(ctx, request) + response, err := Client(srv).Ledger.V2.GetTransaction(ctx, request) if err != nil { return nil, mapSDKError(err) @@ -119,7 +119,7 @@ func GetTransaction(ctx context.Context, srv *Server, request operations.V2GetTr } func GetAccount(ctx context.Context, srv *Server, request operations.V2GetAccountRequest) (*components.V2Account, error) { - response, err := srv.Client().Ledger.V2.GetAccount(ctx, request) + response, err := Client(srv).Ledger.V2.GetAccount(ctx, request) if err != nil { return nil, mapSDKError(err) @@ -129,7 +129,7 @@ func GetAccount(ctx context.Context, srv *Server, request operations.V2GetAccoun } func ListTransactions(ctx context.Context, srv *Server, request operations.V2ListTransactionsRequest) (*components.V2TransactionsCursorResponseCursor, error) { - response, err := srv.Client().Ledger.V2.ListTransactions(ctx, request) + response, err := Client(srv).Ledger.V2.ListTransactions(ctx, request) if err != nil { return nil, mapSDKError(err) @@ -139,7 +139,7 @@ func ListTransactions(ctx context.Context, srv *Server, request operations.V2Lis } func CountTransactions(ctx context.Context, srv *Server, request operations.V2CountTransactionsRequest) (int, error) { - response, err := srv.Client().Ledger.V2.CountTransactions(ctx, request) + response, err := Client(srv).Ledger.V2.CountTransactions(ctx, request) if err != nil { return 0, mapSDKError(err) @@ -154,7 +154,7 @@ func CountTransactions(ctx context.Context, srv *Server, request operations.V2Co } func ListAccounts(ctx context.Context, srv *Server, request operations.V2ListAccountsRequest) (*components.V2AccountsCursorResponseCursor, error) { - response, err := srv.Client().Ledger.V2.ListAccounts(ctx, request) + response, err := Client(srv).Ledger.V2.ListAccounts(ctx, request) if err != nil { return nil, mapSDKError(err) @@ -164,7 +164,7 @@ func ListAccounts(ctx context.Context, srv *Server, request operations.V2ListAcc } func ListLogs(ctx context.Context, srv *Server, request operations.V2ListLogsRequest) (*components.V2LogsCursorResponseCursor, error) { - response, err := srv.Client().Ledger.V2.ListLogs(ctx, request) + response, err := Client(srv).Ledger.V2.ListLogs(ctx, request) if err != nil { return nil, mapSDKError(err) @@ -174,7 +174,7 @@ func ListLogs(ctx context.Context, srv *Server, request operations.V2ListLogsReq } func CountAccounts(ctx context.Context, srv *Server, request operations.V2CountAccountsRequest) (int, error) { - response, err := srv.Client().Ledger.V2.CountAccounts(ctx, request) + response, err := Client(srv).Ledger.V2.CountAccounts(ctx, request) if err != nil { return 0, mapSDKError(err) @@ -189,7 +189,7 @@ func CountAccounts(ctx context.Context, srv *Server, request operations.V2CountA } func ListLedgers(ctx context.Context, srv *Server, request operations.V2ListLedgersRequest) (*components.V2LedgerListResponseCursor, error) { - response, err := srv.Client().Ledger.V2.ListLedgers(ctx, request) + response, err := Client(srv).Ledger.V2.ListLedgers(ctx, request) if err != nil { return nil, mapSDKError(err) @@ -199,7 +199,7 @@ func ListLedgers(ctx context.Context, srv *Server, request operations.V2ListLedg } func GetAggregatedBalances(ctx context.Context, srv *Server, request operations.V2GetBalancesAggregatedRequest) (map[string]*big.Int, error) { - response, err := srv.Client().Ledger.V2.GetBalancesAggregated(ctx, request) + response, err := Client(srv).Ledger.V2.GetBalancesAggregated(ctx, request) if err != nil { return nil, mapSDKError(err) @@ -209,7 +209,7 @@ func GetAggregatedBalances(ctx context.Context, srv *Server, request operations. } func Export(ctx context.Context, srv *Server, request operations.V2ExportLogsRequest) (io.Reader, error) { - response, err := srv.Client().Ledger.V2.ExportLogs(ctx, request) + response, err := Client(srv).Ledger.V2.ExportLogs(ctx, request) if err != nil { return nil, mapSDKError(err) } @@ -223,7 +223,7 @@ func Export(ctx context.Context, srv *Server, request operations.V2ExportLogsReq } func Import(ctx context.Context, srv *Server, request operations.V2ImportLogsRequest) error { - _, err := srv.Client().Ledger.V2.ImportLogs(ctx, request) + _, err := Client(srv).Ledger.V2.ImportLogs(ctx, request) return mapSDKError(err) } diff --git a/pkg/testserver/client.go b/pkg/testserver/client.go new file mode 100644 index 0000000000..e91d428859 --- /dev/null +++ b/pkg/testserver/client.go @@ -0,0 +1,12 @@ +package testserver + +import ( + "github.com/formancehq/go-libs/v2/testing/testservice" + ledgerclient "github.com/formancehq/ledger/pkg/client" +) + +func Client(srv *testservice.Service[ServeConfiguration]) *ledgerclient.Formance { + return ledgerclient.New( + ledgerclient.WithServerURL(testservice.GetServerURL(srv)), + ) +} diff --git a/pkg/testserver/helpers.go b/pkg/testserver/helpers.go index 4aae28124e..5eed64c761 100644 --- a/pkg/testserver/helpers.go +++ b/pkg/testserver/helpers.go @@ -1,36 +1,18 @@ package testserver import ( + "context" + "github.com/formancehq/go-libs/v2/bun/bunconnect" "github.com/formancehq/go-libs/v2/collectionutils" "github.com/formancehq/go-libs/v2/pointer" - . "github.com/formancehq/go-libs/v2/testing/utils" "github.com/formancehq/go-libs/v2/time" "github.com/formancehq/ledger/internal" "github.com/formancehq/ledger/pkg/client/models/components" "github.com/nats-io/nats.go" - . "github.com/onsi/ginkgo/v2" "github.com/stretchr/testify/require" "github.com/uptrace/bun" ) -func NewTestServer(configurationProvider func() Configuration) *Deferred[*Server] { - d := NewDeferred[*Server]() - BeforeEach(func() { - d.Reset() - d.SetValue(New(GinkgoT(), configurationProvider())) - }) - return d -} - -func NewTestWorker(configurationProvider func() WorkerServiceConfiguration) *Deferred[*Worker] { - d := NewDeferred[*Worker]() - BeforeEach(func() { - d.Reset() - d.SetValue(NewWorker(GinkgoT(), configurationProvider())) - }) - return d -} - func ConvertSDKTxToCoreTX(tx *components.V2Transaction) ledger.Transaction { return ledger.Transaction{ TransactionData: ledger.TransactionData{ @@ -77,22 +59,28 @@ func ConvertSDKPostingToCorePosting(p components.V2Posting) ledger.Posting { } } -func Subscribe(t T, testServer *Server) chan *nats.Msg { - subscription, ch, err := testServer.Subscribe() +func ConnectToDatabase(ctx context.Context, t interface{ + require.TestingT + Cleanup(func()) +}, testServer *Server) *bun.DB { + db, err := bunconnect.OpenSQLDB(ctx, bunconnect.ConnectionOptions(testServer.GetConfiguration().Configuration.PostgresConfiguration)) require.NoError(t, err) t.Cleanup(func() { - require.NoError(t, subscription.Unsubscribe()) + require.NoError(t, db.Close()) }) - - return ch + return db } -func ConnectToDatabase(t T, testServer *Server) *bun.DB { - db, err := testServer.Database() +func Subscribe(t require.TestingT, server *Server) (*nats.Subscription, chan *nats.Msg) { + ret := make(chan *nats.Msg) + conn, err := nats.Connect(server.GetConfiguration().Configuration.NatsURL) require.NoError(t, err) - t.Cleanup(func() { - require.NoError(t, db.Close()) + + subscription, err := conn.Subscribe(server.GetID(), func(msg *nats.Msg) { + ret <- msg }) - return db + require.NoError(t, err) + + return subscription, ret } diff --git a/pkg/testserver/server.go b/pkg/testserver/server.go index 6140e87f00..e9d9a38eda 100644 --- a/pkg/testserver/server.go +++ b/pkg/testserver/server.go @@ -1,135 +1,34 @@ package testserver import ( - "context" - "errors" "fmt" - "github.com/nats-io/nats.go" - "io" - "net/http" - "strings" - "time" - - "github.com/formancehq/go-libs/v2/otlp" - "github.com/formancehq/go-libs/v2/otlp/otlpmetrics" - "github.com/formancehq/go-libs/v2/publish" - "github.com/google/uuid" - "github.com/uptrace/bun" - "github.com/formancehq/go-libs/v2/bun/bunconnect" - "github.com/formancehq/go-libs/v2/httpclient" - "github.com/formancehq/go-libs/v2/httpserver" - "github.com/formancehq/go-libs/v2/logging" - "github.com/formancehq/go-libs/v2/service" + "github.com/formancehq/go-libs/v2/publish" + "github.com/formancehq/go-libs/v2/testing/testservice" "github.com/formancehq/ledger/cmd" - ledgerclient "github.com/formancehq/ledger/pkg/client" - "github.com/stretchr/testify/require" ) -type T interface { - require.TestingT - Cleanup(func()) - Helper() - Logf(format string, args ...any) -} +type PostgresConfiguration bunconnect.ConnectionOptions -type OTLPConfig struct { - BaseConfig otlp.Config - Metrics *otlpmetrics.ModuleConfig -} - -type CommonConfiguration struct { - PostgresConfiguration bunconnect.ConnectionOptions - Output io.Writer - Debug bool - OTLPConfig *OTLPConfig -} - -func (cfg CommonConfiguration) computeCommonFlags() []string { - args := []string{ - "--" + bunconnect.PostgresURIFlag, cfg.PostgresConfiguration.DatabaseSourceName, +func (cfg PostgresConfiguration) GetArgs() []string { + args := make([]string, 0) + if cfg.DatabaseSourceName != "" { + args = append(args, "--"+bunconnect.PostgresURIFlag, cfg.DatabaseSourceName) } - if cfg.PostgresConfiguration.MaxIdleConns != 0 { - args = append( - args, - "--"+bunconnect.PostgresMaxIdleConnsFlag, - fmt.Sprint(cfg.PostgresConfiguration.MaxIdleConns), - ) + if cfg.MaxIdleConns != 0 { + args = append(args, "--"+bunconnect.PostgresMaxIdleConnsFlag, fmt.Sprint(cfg.MaxIdleConns)) } - if cfg.PostgresConfiguration.MaxOpenConns != 0 { - args = append( - args, - "--"+bunconnect.PostgresMaxOpenConnsFlag, - fmt.Sprint(cfg.PostgresConfiguration.MaxOpenConns), - ) + if cfg.MaxOpenConns != 0 { + args = append(args, "--"+bunconnect.PostgresMaxOpenConnsFlag, fmt.Sprint(cfg.MaxOpenConns)) } - if cfg.PostgresConfiguration.ConnMaxIdleTime != 0 { - args = append( - args, - "--"+bunconnect.PostgresConnMaxIdleTimeFlag, - fmt.Sprint(cfg.PostgresConfiguration.ConnMaxIdleTime), - ) + if cfg.ConnMaxIdleTime != 0 { + args = append(args, "--"+bunconnect.PostgresConnMaxIdleTimeFlag, fmt.Sprint(cfg.ConnMaxIdleTime)) } - if cfg.OTLPConfig != nil { - if cfg.OTLPConfig.Metrics != nil { - args = append( - args, - "--"+otlpmetrics.OtelMetricsExporterFlag, cfg.OTLPConfig.Metrics.Exporter, - ) - if cfg.OTLPConfig.Metrics.KeepInMemory { - args = append( - args, - "--"+otlpmetrics.OtelMetricsKeepInMemoryFlag, - ) - } - if cfg.OTLPConfig.Metrics.OTLPConfig != nil { - args = append( - args, - "--"+otlpmetrics.OtelMetricsExporterOTLPEndpointFlag, cfg.OTLPConfig.Metrics.OTLPConfig.Endpoint, - "--"+otlpmetrics.OtelMetricsExporterOTLPModeFlag, cfg.OTLPConfig.Metrics.OTLPConfig.Mode, - ) - if cfg.OTLPConfig.Metrics.OTLPConfig.Insecure { - args = append(args, "--"+otlpmetrics.OtelMetricsExporterOTLPInsecureFlag) - } - } - if cfg.OTLPConfig.Metrics.RuntimeMetrics { - args = append(args, "--"+otlpmetrics.OtelMetricsRuntimeFlag) - } - if cfg.OTLPConfig.Metrics.MinimumReadMemStatsInterval != 0 { - args = append( - args, - "--"+otlpmetrics.OtelMetricsRuntimeMinimumReadMemStatsIntervalFlag, - cfg.OTLPConfig.Metrics.MinimumReadMemStatsInterval.String(), - ) - } - if cfg.OTLPConfig.Metrics.PushInterval != 0 { - args = append( - args, - "--"+otlpmetrics.OtelMetricsExporterPushIntervalFlag, - cfg.OTLPConfig.Metrics.PushInterval.String(), - ) - } - if len(cfg.OTLPConfig.Metrics.ResourceAttributes) > 0 { - args = append( - args, - "--"+otlp.OtelResourceAttributesFlag, - strings.Join(cfg.OTLPConfig.Metrics.ResourceAttributes, ","), - ) - } - } - if cfg.OTLPConfig.BaseConfig.ServiceName != "" { - args = append(args, "--"+otlp.OtelServiceNameFlag, cfg.OTLPConfig.BaseConfig.ServiceName) - } - } - if cfg.Debug { - args = append(args, "--"+service.DebugFlag) - } - return args } -type Configuration struct { - CommonConfiguration +type ServeConfiguration struct { + PostgresConfiguration PostgresConfiguration NatsURL string ExperimentalFeatures bool DisableAutoUpgrade bool @@ -141,224 +40,56 @@ type Configuration struct { WorkerConfiguration *WorkerConfiguration } -type Logger interface { - Logf(fmt string, args ...any) -} - -type Server struct { - configuration Configuration - logger Logger - sdkClient *ledgerclient.Formance - cancel func() - ctx context.Context - errorChan chan error - id string - httpClient *http.Client - serverURL string -} - -func (s *Server) Start() error { - rootCmd := cmd.NewRootCommand() +func (cfg ServeConfiguration) GetArgs(serverID string) []string { args := []string{ "serve", "--" + cmd.BindFlag, ":0", } - args = append(args, s.configuration.computeCommonFlags()...) - if !s.configuration.DisableAutoUpgrade { + args = append(args, cfg.PostgresConfiguration.GetArgs()...) + if !cfg.DisableAutoUpgrade { args = append(args, "--"+cmd.AutoUpgradeFlag) } - if s.configuration.WorkerEnabled { + if cfg.WorkerEnabled { args = append(args, "--"+cmd.WorkerEnabledFlag) - if s.configuration.WorkerConfiguration != nil { - args = append(args, s.configuration.WorkerConfiguration.computeFlags()...) + if cfg.WorkerConfiguration != nil { + args = append(args, cfg.WorkerConfiguration.GetArgs(serverID)...) } } - if s.configuration.ExperimentalFeatures { + if cfg.ExperimentalFeatures { args = append( args, "--"+cmd.ExperimentalFeaturesFlag, ) } - if s.configuration.BulkMaxSize != 0 { + if cfg.BulkMaxSize != 0 { args = append( args, "--"+cmd.BulkMaxSizeFlag, - fmt.Sprint(s.configuration.BulkMaxSize), + fmt.Sprint(cfg.BulkMaxSize), ) } - if s.configuration.ExperimentalNumscriptRewrite { + if cfg.ExperimentalNumscriptRewrite { args = append( args, "--"+cmd.NumscriptInterpreterFlag, ) } - if s.configuration.NatsURL != "" { + if cfg.NatsURL != "" { args = append( args, "--"+publish.PublisherNatsEnabledFlag, - "--"+publish.PublisherNatsURLFlag, s.configuration.NatsURL, - "--"+publish.PublisherTopicMappingFlag, fmt.Sprintf("*:%s", s.id), + "--"+publish.PublisherNatsURLFlag, cfg.NatsURL, + "--"+publish.PublisherTopicMappingFlag, fmt.Sprintf("*:%s", serverID), ) } - if s.configuration.MaxPageSize != 0 { - args = append(args, "--"+cmd.MaxPageSizeFlag, fmt.Sprint(s.configuration.MaxPageSize)) - } - if s.configuration.DefaultPageSize != 0 { - args = append(args, "--"+cmd.DefaultPageSizeFlag, fmt.Sprint(s.configuration.DefaultPageSize)) - } - - s.logger.Logf("Starting application with flags: %s", strings.Join(args, " ")) - rootCmd.SetArgs(args) - rootCmd.SilenceErrors = true - output := s.configuration.Output - if output == nil { - output = io.Discard - } - rootCmd.SetOut(output) - rootCmd.SetErr(output) - - ctx := logging.TestingContext() - ctx = service.ContextWithLifecycle(ctx) - ctx = httpserver.ContextWithServerInfo(ctx) - ctx, cancel := context.WithCancel(ctx) - - go func() { - s.errorChan <- rootCmd.ExecuteContext(ctx) - }() - - select { - case <-service.Ready(ctx): - case err := <-s.errorChan: - cancel() - if err != nil { - return err - } - - return errors.New("unexpected service stop") - } - - s.ctx, s.cancel = ctx, cancel - - var transport http.RoundTripper = &http.Transport{ - MaxIdleConns: 100, - MaxIdleConnsPerHost: 100, - MaxConnsPerHost: 100, + if cfg.MaxPageSize != 0 { + args = append(args, "--"+cmd.MaxPageSizeFlag, fmt.Sprint(cfg.MaxPageSize)) } - if s.configuration.Debug { - transport = httpclient.NewDebugHTTPTransport(transport) + if cfg.DefaultPageSize != 0 { + args = append(args, "--"+cmd.DefaultPageSizeFlag, fmt.Sprint(cfg.DefaultPageSize)) } - s.httpClient = &http.Client{ - Transport: transport, - } - s.serverURL = httpserver.URL(s.ctx) - - s.sdkClient = ledgerclient.New( - ledgerclient.WithServerURL(s.serverURL), - ledgerclient.WithClient(s.httpClient), - ) - - return nil -} - -func (s *Server) Stop(ctx context.Context) error { - if s.cancel == nil { - return nil - } - s.cancel() - s.cancel = nil - - // Wait app to be marked as stopped - select { - case <-service.Stopped(s.ctx): - case <-ctx.Done(): - return errors.New("service should have been stopped") - } - - // Ensure the app has been properly shutdown - select { - case err := <-s.errorChan: - return err - case <-ctx.Done(): - return errors.New("service should have been stopped without error") - } -} - -func (s *Server) Client() *ledgerclient.Formance { - return s.sdkClient -} - -func (s *Server) HTTPClient() *http.Client { - return s.httpClient -} - -func (s *Server) ServerURL() string { - return s.serverURL -} - -func (s *Server) Restart(ctx context.Context) error { - if err := s.Stop(ctx); err != nil { - return err - } - if err := s.Start(); err != nil { - return err - } - - return nil -} - -func (s *Server) Database() (*bun.DB, error) { - db, err := bunconnect.OpenSQLDB(s.ctx, s.configuration.PostgresConfiguration) - if err != nil { - return nil, err - } - - return db, nil -} - -func (s *Server) Subscribe() (*nats.Subscription, chan *nats.Msg, error) { - if s.configuration.NatsURL == "" { - return nil, nil, errors.New("NATS URL must be set") - } - - ret := make(chan *nats.Msg) - conn, err := nats.Connect(s.configuration.NatsURL) - if err != nil { - return nil, nil, err - } - - subscription, err := conn.Subscribe(s.id, func(msg *nats.Msg) { - ret <- msg - }) - if err != nil { - return nil, nil, err - } - - return subscription, ret, nil -} - -func (s *Server) URL() string { - return httpserver.URL(s.ctx) + return args } -func New(t T, configuration Configuration) *Server { - t.Helper() - - srv := &Server{ - logger: t, - configuration: configuration, - id: uuid.NewString()[:8], - errorChan: make(chan error, 1), - } - t.Logf("Start testing server") - require.NoError(t, srv.Start()) - t.Cleanup(func() { - t.Logf("Stop testing server") - ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) - defer cancel() - - require.NoError(t, srv.Stop(ctx)) - }) - - return srv -} +type Server = testservice.Service[ServeConfiguration] diff --git a/pkg/testserver/utils.go b/pkg/testserver/utils.go new file mode 100644 index 0000000000..b754ae0774 --- /dev/null +++ b/pkg/testserver/utils.go @@ -0,0 +1,46 @@ +package testserver + +import ( + "github.com/formancehq/go-libs/v2/testing/testservice" + "github.com/formancehq/go-libs/v2/testing/utils" + "github.com/formancehq/ledger/cmd" + "github.com/onsi/ginkgo/v2/dsl/core" + "io" +) + +func DeferTestServer(debug bool, output io.Writer, configurationProvider func() ServeConfiguration) *utils.Deferred[*Server] { + return testservice.DeferNew[ServeConfiguration]( + cmd.NewRootCommand, + func() testservice.Configuration[ServeConfiguration] { + return testservice.Configuration[ServeConfiguration]{ + CommonConfiguration: testservice.CommonConfiguration{ + Debug: debug, + Output: output, + }, + Configuration: configurationProvider(), + } + }, + testservice.WithLogger(core.GinkgoT()), + testservice.WithInstruments(testservice.HTTPServerInstrumentation()), + ) +} + +func NewTestServer(configuration testservice.Configuration[ServeConfiguration], options ...testservice.Option) *testservice.Service[ServeConfiguration] { + return testservice.New[ServeConfiguration]( + cmd.NewRootCommand, + configuration, + append(options, testservice.WithInstruments(testservice.HTTPServerInstrumentation()))..., + ) +} + +func DeferTestWorker(debug bool, output io.Writer, configurationProvider func() WorkerConfiguration) *utils.Deferred[*Worker] { + return testservice.DeferNew[WorkerConfiguration](cmd.NewRootCommand, func() testservice.Configuration[WorkerConfiguration] { + return testservice.Configuration[WorkerConfiguration]{ + CommonConfiguration: testservice.CommonConfiguration{ + Debug: debug, + Output: output, + }, + Configuration: configurationProvider(), + } + }) +} diff --git a/pkg/testserver/worker.go b/pkg/testserver/worker.go index 35b79e8ca8..a1e6b32f92 100644 --- a/pkg/testserver/worker.go +++ b/pkg/testserver/worker.go @@ -1,34 +1,20 @@ package testserver import ( - "context" - "errors" - "io" - "net/http" - "strconv" - "strings" - "time" - - "github.com/google/uuid" - "github.com/uptrace/bun" - - "github.com/formancehq/go-libs/v2/bun/bunconnect" - "github.com/formancehq/go-libs/v2/httpclient" - "github.com/formancehq/go-libs/v2/httpserver" - "github.com/formancehq/go-libs/v2/logging" - "github.com/formancehq/go-libs/v2/service" + "github.com/formancehq/go-libs/v2/testing/testservice" "github.com/formancehq/ledger/cmd" - ledgerclient "github.com/formancehq/ledger/pkg/client" - "github.com/stretchr/testify/require" + "strconv" ) type WorkerConfiguration struct { + PostgresConfiguration PostgresConfiguration LogsHashBlockMaxSize int LogsHashBlockCRONSpec string } -func (cfg WorkerConfiguration) computeFlags() []string { - args := make([]string, 0) +func (cfg WorkerConfiguration) GetArgs(_ string) []string { + args := []string{"worker"} + args = append(args, cfg.PostgresConfiguration.GetArgs()...) if cfg.LogsHashBlockMaxSize > 0 { args = append(args, "--"+cmd.WorkerAsyncBlockHasherMaxBlockSizeFlag, strconv.Itoa(cfg.LogsHashBlockMaxSize)) } @@ -39,163 +25,4 @@ func (cfg WorkerConfiguration) computeFlags() []string { return args } -type WorkerServiceConfiguration struct { - CommonConfiguration - WorkerConfiguration - Output io.Writer -} - -type Worker struct { - configuration WorkerServiceConfiguration - logger Logger - sdkClient *ledgerclient.Formance - cancel func() - ctx context.Context - errorChan chan error - id string - httpClient *http.Client - serverURL string -} - -func (s *Worker) Start() error { - rootCmd := cmd.NewRootCommand() - args := []string{ - "worker", - } - args = append(args, s.configuration.computeCommonFlags()...) - args = append(args, s.configuration.WorkerConfiguration.computeFlags()...) - - s.logger.Logf("Starting application with flags: %s", strings.Join(args, " ")) - rootCmd.SetArgs(args) - rootCmd.SilenceErrors = true - output := s.configuration.Output - if output == nil { - output = io.Discard - } - rootCmd.SetOut(output) - rootCmd.SetErr(output) - - ctx := logging.TestingContext() - ctx = service.ContextWithLifecycle(ctx) - ctx = httpserver.ContextWithServerInfo(ctx) - ctx, cancel := context.WithCancel(ctx) - - go func() { - s.errorChan <- rootCmd.ExecuteContext(ctx) - }() - - select { - case <-service.Ready(ctx): - case err := <-s.errorChan: - cancel() - if err != nil { - return err - } - - return errors.New("unexpected service stop") - } - - s.ctx, s.cancel = ctx, cancel - - var transport http.RoundTripper = &http.Transport{ - MaxIdleConns: 100, - MaxIdleConnsPerHost: 100, - MaxConnsPerHost: 100, - } - if s.configuration.Debug { - transport = httpclient.NewDebugHTTPTransport(transport) - } - - s.httpClient = &http.Client{ - Transport: transport, - } - s.serverURL = httpserver.URL(s.ctx) - - s.sdkClient = ledgerclient.New( - ledgerclient.WithServerURL(s.serverURL), - ledgerclient.WithClient(s.httpClient), - ) - - return nil -} - -func (s *Worker) Stop(ctx context.Context) error { - if s.cancel == nil { - return nil - } - s.cancel() - s.cancel = nil - - // Wait app to be marked as stopped - select { - case <-service.Stopped(s.ctx): - case <-ctx.Done(): - return errors.New("service should have been stopped") - } - - // Ensure the app has been properly shutdown - select { - case err := <-s.errorChan: - return err - case <-ctx.Done(): - return errors.New("service should have been stopped without error") - } -} - -func (s *Worker) Client() *ledgerclient.Formance { - return s.sdkClient -} - -func (s *Worker) HTTPClient() *http.Client { - return s.httpClient -} - -func (s *Worker) ServerURL() string { - return s.serverURL -} - -func (s *Worker) Restart(ctx context.Context) error { - if err := s.Stop(ctx); err != nil { - return err - } - if err := s.Start(); err != nil { - return err - } - - return nil -} - -func (s *Worker) Database() (*bun.DB, error) { - db, err := bunconnect.OpenSQLDB(s.ctx, s.configuration.PostgresConfiguration) - if err != nil { - return nil, err - } - - return db, nil -} - -func (s *Worker) URL() string { - return httpserver.URL(s.ctx) -} - -func NewWorker(t T, configuration WorkerServiceConfiguration) *Worker { - t.Helper() - - srv := &Worker{ - logger: t, - configuration: configuration, - id: uuid.NewString()[:8], - errorChan: make(chan error, 1), - } - t.Logf("Start testing server") - require.NoError(t, srv.Start()) - t.Cleanup(func() { - t.Logf("Stop testing server") - ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) - defer cancel() - - require.NoError(t, srv.Stop(ctx)) - }) - - return srv -} +type Worker = testservice.Service[WorkerConfiguration] diff --git a/test/e2e/api_accounts_list_test.go b/test/e2e/api_accounts_list_test.go index 2b1a115aae..ca444f7118 100644 --- a/test/e2e/api_accounts_list_test.go +++ b/test/e2e/api_accounts_list_test.go @@ -26,14 +26,10 @@ var _ = Context("Ledger accounts list API tests", func() { ctx = logging.TestingContext() ) - testServer := NewTestServer(func() Configuration { - return Configuration{ - CommonConfiguration: CommonConfiguration{ - PostgresConfiguration: db.GetValue().ConnectionOptions(), - Output: GinkgoWriter, - Debug: debug, - }, - NatsURL: natsServer.GetValue().ClientURL(), + testServer := DeferTestServer(debug, GinkgoWriter, func() ServeConfiguration { + return ServeConfiguration{ + PostgresConfiguration: PostgresConfiguration(db.GetValue().ConnectionOptions()), + NatsURL: natsServer.GetValue().ClientURL(), } }) BeforeEach(func() { diff --git a/test/e2e/api_accounts_metadata_test.go b/test/e2e/api_accounts_metadata_test.go index be43864082..73e3b067f8 100644 --- a/test/e2e/api_accounts_metadata_test.go +++ b/test/e2e/api_accounts_metadata_test.go @@ -19,19 +19,15 @@ var _ = Context("Ledger accounts metadata API tests", func() { ctx = logging.TestingContext() ) - testServer := NewTestServer(func() Configuration { - return Configuration{ - CommonConfiguration: CommonConfiguration{ - PostgresConfiguration: db.GetValue().ConnectionOptions(), - Output: GinkgoWriter, - Debug: debug, - }, - NatsURL: natsServer.GetValue().ClientURL(), + testServer := DeferTestServer(debug, GinkgoWriter, func() ServeConfiguration { + return ServeConfiguration{ + PostgresConfiguration: PostgresConfiguration(db.GetValue().ConnectionOptions()), + NatsURL: natsServer.GetValue().ClientURL(), } }) var events chan *nats.Msg BeforeEach(func() { - events = Subscribe(GinkgoT(), testServer.GetValue()) + _, events = Subscribe(GinkgoT(), testServer.GetValue()) }) BeforeEach(func() { diff --git a/test/e2e/api_balances_aggregated_test.go b/test/e2e/api_balances_aggregated_test.go index 705ca6b7a2..492e979743 100644 --- a/test/e2e/api_balances_aggregated_test.go +++ b/test/e2e/api_balances_aggregated_test.go @@ -21,14 +21,10 @@ var _ = Context("Ledger engine tests", func() { ctx = logging.TestingContext() ) - testServer := NewTestServer(func() Configuration { - return Configuration{ - CommonConfiguration: CommonConfiguration{ - PostgresConfiguration: db.GetValue().ConnectionOptions(), - Output: GinkgoWriter, - Debug: debug, - }, - NatsURL: natsServer.GetValue().ClientURL(), + testServer := DeferTestServer(debug, GinkgoWriter, func() ServeConfiguration { + return ServeConfiguration{ + PostgresConfiguration: PostgresConfiguration(db.GetValue().ConnectionOptions()), + NatsURL: natsServer.GetValue().ClientURL(), } }) now := time.Now().UTC().Round(time.Second) diff --git a/test/e2e/api_bulk_test.go b/test/e2e/api_bulk_test.go index 8255afc96b..bbf5318667 100644 --- a/test/e2e/api_bulk_test.go +++ b/test/e2e/api_bulk_test.go @@ -6,6 +6,7 @@ import ( "bytes" "encoding/json" "github.com/formancehq/go-libs/v2/pointer" + "github.com/formancehq/go-libs/v2/testing/testservice" ledger "github.com/formancehq/ledger/internal" "github.com/formancehq/ledger/internal/bus" ledgerevents "github.com/formancehq/ledger/pkg/events" @@ -35,15 +36,11 @@ var _ = Context("Ledger engine tests", func() { bulkMaxSize = 100 ) - testServer := NewTestServer(func() Configuration { - return Configuration{ - CommonConfiguration: CommonConfiguration{ - PostgresConfiguration: db.GetValue().ConnectionOptions(), - Output: GinkgoWriter, - Debug: debug, - }, - NatsURL: natsServer.GetValue().ClientURL(), - BulkMaxSize: bulkMaxSize, + testServer := DeferTestServer(debug, GinkgoWriter, func() ServeConfiguration { + return ServeConfiguration{ + PostgresConfiguration: PostgresConfiguration(db.GetValue().ConnectionOptions()), + NatsURL: natsServer.GetValue().ClientURL(), + BulkMaxSize: bulkMaxSize, } }) BeforeEach(func() { @@ -51,7 +48,7 @@ var _ = Context("Ledger engine tests", func() { Ledger: "default", }) Expect(err).To(BeNil()) - events = Subscribe(GinkgoT(), testServer.GetValue()) + _, events = Subscribe(GinkgoT(), testServer.GetValue()) }) When("creating a bulk on a ledger", func() { var ( @@ -241,7 +238,7 @@ var _ = Context("Ledger engine tests", func() { } stream.Write([]byte("\n")) - req, err := http.NewRequest(http.MethodPost, testServer.GetValue().URL()+"/v2/default/_bulk", stream) + req, err := http.NewRequest(http.MethodPost, testservice.GetServerURL(testServer.GetValue())+"/v2/default/_bulk", stream) req.Header.Set("Content-Type", "application/vnd.formance.ledger.api.v2.bulk+json-stream") Expect(err).To(Succeed()) diff --git a/test/e2e/api_ledgers_create_test.go b/test/e2e/api_ledgers_create_test.go index 157e3d7407..eb05f09d94 100644 --- a/test/e2e/api_ledgers_create_test.go +++ b/test/e2e/api_ledgers_create_test.go @@ -21,15 +21,11 @@ var _ = Context("Ledger engine tests", func() { ctx = logging.TestingContext() ) - testServer := NewTestServer(func() Configuration { - return Configuration{ - CommonConfiguration: CommonConfiguration{ - PostgresConfiguration: db.GetValue().ConnectionOptions(), - Output: GinkgoWriter, - Debug: debug, - }, - NatsURL: natsServer.GetValue().ClientURL(), - ExperimentalFeatures: true, + testServer := DeferTestServer(debug, GinkgoWriter, func() ServeConfiguration { + return ServeConfiguration{ + PostgresConfiguration: PostgresConfiguration(db.GetValue().ConnectionOptions()), + NatsURL: natsServer.GetValue().ClientURL(), + ExperimentalFeatures: true, } }) When("creating a new ledger", func() { diff --git a/test/e2e/api_ledgers_import_test.go b/test/e2e/api_ledgers_import_test.go index 3648bf4aec..7cd321080d 100644 --- a/test/e2e/api_ledgers_import_test.go +++ b/test/e2e/api_ledgers_import_test.go @@ -24,15 +24,11 @@ var _ = Context("Ledger engine tests", func() { ctx = logging.TestingContext() ) - testServer := NewTestServer(func() Configuration { - return Configuration{ - CommonConfiguration: CommonConfiguration{ - PostgresConfiguration: db.GetValue().ConnectionOptions(), - Output: GinkgoWriter, - Debug: debug, - }, - NatsURL: natsServer.GetValue().ClientURL(), - ExperimentalFeatures: true, + testServer := DeferTestServer(debug, GinkgoWriter, func() ServeConfiguration { + return ServeConfiguration{ + PostgresConfiguration: PostgresConfiguration(db.GetValue().ConnectionOptions()), + NatsURL: natsServer.GetValue().ClientURL(), + ExperimentalFeatures: true, } }) When("creating a new ledger", func() { @@ -335,7 +331,7 @@ var _ = Context("Ledger engine tests", func() { // we take a lock on the ledgers table to force the process to wait // while we will make a concurrent request JustBeforeEach(func() { - db = ConnectToDatabase(GinkgoT(), testServer.GetValue()) + db = ConnectToDatabase(ctx, GinkgoT(), testServer.GetValue()) sqlTx, err = db.BeginTx(ctx, &sql.TxOptions{}) Expect(err).To(BeNil()) diff --git a/test/e2e/api_ledgers_list_test.go b/test/e2e/api_ledgers_list_test.go index bf4efaed17..ba7c06da37 100644 --- a/test/e2e/api_ledgers_list_test.go +++ b/test/e2e/api_ledgers_list_test.go @@ -19,16 +19,12 @@ var _ = Context("Ledger engine tests", func() { ctx = logging.TestingContext() ) - testServer := NewTestServer(func() Configuration { - return Configuration{ - CommonConfiguration: CommonConfiguration{ - PostgresConfiguration: db.GetValue().ConnectionOptions(), - Output: GinkgoWriter, - Debug: debug, - }, - NatsURL: natsServer.GetValue().ClientURL(), - MaxPageSize: 15, - DefaultPageSize: 15, + testServer := DeferTestServer(debug, GinkgoWriter, func() ServeConfiguration { + return ServeConfiguration{ + PostgresConfiguration: PostgresConfiguration(db.GetValue().ConnectionOptions()), + NatsURL: natsServer.GetValue().ClientURL(), + MaxPageSize: 15, + DefaultPageSize: 15, } }) diff --git a/test/e2e/api_ledgers_metadata_test.go b/test/e2e/api_ledgers_metadata_test.go index 7293f0ba18..abd52ffa0e 100644 --- a/test/e2e/api_ledgers_metadata_test.go +++ b/test/e2e/api_ledgers_metadata_test.go @@ -16,14 +16,10 @@ var _ = Context("Ledger engine tests", func() { ctx = logging.TestingContext() ) - testServer := NewTestServer(func() Configuration { - return Configuration{ - CommonConfiguration: CommonConfiguration{ - PostgresConfiguration: db.GetValue().ConnectionOptions(), - Output: GinkgoWriter, - Debug: debug, - }, - NatsURL: natsServer.GetValue().ClientURL(), + testServer := DeferTestServer(debug, GinkgoWriter, func() ServeConfiguration { + return ServeConfiguration{ + PostgresConfiguration: PostgresConfiguration(db.GetValue().ConnectionOptions()), + NatsURL: natsServer.GetValue().ClientURL(), } }) When("creating a ledger", func() { diff --git a/test/e2e/api_logs_list_test.go b/test/e2e/api_logs_list_test.go index 6f20615546..11bea154c6 100644 --- a/test/e2e/api_logs_list_test.go +++ b/test/e2e/api_logs_list_test.go @@ -22,14 +22,10 @@ var _ = Context("Ledger logs list API tests", func() { ctx = logging.TestingContext() ) - testServer := NewTestServer(func() Configuration { - return Configuration{ - CommonConfiguration: CommonConfiguration{ - PostgresConfiguration: db.GetValue().ConnectionOptions(), - Output: GinkgoWriter, - Debug: debug, - }, - NatsURL: natsServer.GetValue().ClientURL(), + testServer := DeferTestServer(debug, GinkgoWriter, func() ServeConfiguration { + return ServeConfiguration{ + PostgresConfiguration: PostgresConfiguration(db.GetValue().ConnectionOptions()), + NatsURL: natsServer.GetValue().ClientURL(), } }) BeforeEach(func() { diff --git a/test/e2e/api_transactions_create_test.go b/test/e2e/api_transactions_create_test.go index b284dcd0cd..1cecc4b3c1 100644 --- a/test/e2e/api_transactions_create_test.go +++ b/test/e2e/api_transactions_create_test.go @@ -35,13 +35,9 @@ var _ = Context("Ledger transactions create API tests", func() { db = UseTemplatedDatabase() ctx = logging.TestingContext() ) - testServer := NewTestServer(func() Configuration { - return Configuration{ - CommonConfiguration: CommonConfiguration{ - PostgresConfiguration: db.GetValue().ConnectionOptions(), - Output: GinkgoWriter, - Debug: debug, - }, + testServer := DeferTestServer(debug, GinkgoWriter, func() ServeConfiguration { + return ServeConfiguration{ + PostgresConfiguration: PostgresConfiguration(db.GetValue().ConnectionOptions()), NatsURL: natsServer.GetValue().ClientURL(), ExperimentalNumscriptRewrite: data.numscriptRewrite, } @@ -68,7 +64,7 @@ var _ = Context("Ledger transactions create API tests", func() { err error ) BeforeEach(func() { - events = Subscribe(GinkgoT(), testServer.GetValue()) + _, events = Subscribe(GinkgoT(), testServer.GetValue()) req = operations.V2CreateTransactionRequest{ V2PostTransaction: components.V2PostTransaction{ Timestamp: ×tamp, @@ -590,7 +586,7 @@ var _ = Context("Ledger transactions create API tests", func() { ) BeforeEach(func() { v, _ := big.NewInt(0).SetString("1320000000000000000000000000000000000000000000000001", 10) - response, err = testServer.GetValue().Client().Ledger.V1.CreateTransaction( + response, err = Client(testServer.GetValue()).Ledger.V1.CreateTransaction( ctx, operations.CreateTransactionRequest{ PostTransaction: components.PostTransaction{ diff --git a/test/e2e/api_transactions_list_test.go b/test/e2e/api_transactions_list_test.go index d757c021d7..38606df999 100644 --- a/test/e2e/api_transactions_list_test.go +++ b/test/e2e/api_transactions_list_test.go @@ -29,14 +29,10 @@ var _ = Context("Ledger transactions list API tests", func() { ctx = logging.TestingContext() ) - testServer := NewTestServer(func() Configuration { - return Configuration{ - CommonConfiguration: CommonConfiguration{ - PostgresConfiguration: db.GetValue().ConnectionOptions(), - Output: GinkgoWriter, - Debug: debug, - }, - NatsURL: natsServer.GetValue().ClientURL(), + testServer := DeferTestServer(debug, GinkgoWriter, func() ServeConfiguration { + return ServeConfiguration{ + PostgresConfiguration: PostgresConfiguration(db.GetValue().ConnectionOptions()), + NatsURL: natsServer.GetValue().ClientURL(), } }) JustBeforeEach(func() { diff --git a/test/e2e/api_transactions_metadata_test.go b/test/e2e/api_transactions_metadata_test.go index c1f02fd301..586a68b5c7 100644 --- a/test/e2e/api_transactions_metadata_test.go +++ b/test/e2e/api_transactions_metadata_test.go @@ -21,14 +21,10 @@ var _ = Context("Ledger accounts list API tests", func() { ctx = logging.TestingContext() ) - testServer := NewTestServer(func() Configuration { - return Configuration{ - CommonConfiguration: CommonConfiguration{ - PostgresConfiguration: db.GetValue().ConnectionOptions(), - Output: GinkgoWriter, - Debug: debug, - }, - NatsURL: natsServer.GetValue().ClientURL(), + testServer := DeferTestServer(debug, GinkgoWriter, func() ServeConfiguration { + return ServeConfiguration{ + PostgresConfiguration: PostgresConfiguration(db.GetValue().ConnectionOptions()), + NatsURL: natsServer.GetValue().ClientURL(), } }) BeforeEach(func() { diff --git a/test/e2e/api_transactions_revert_test.go b/test/e2e/api_transactions_revert_test.go index 149f00d1dd..8a153d4bab 100644 --- a/test/e2e/api_transactions_revert_test.go +++ b/test/e2e/api_transactions_revert_test.go @@ -26,14 +26,10 @@ var _ = Context("Ledger revert transactions API tests", func() { ctx = logging.TestingContext() ) - testServer := NewTestServer(func() Configuration { - return Configuration{ - CommonConfiguration: CommonConfiguration{ - PostgresConfiguration: db.GetValue().ConnectionOptions(), - Output: GinkgoWriter, - Debug: debug, - }, - NatsURL: natsServer.GetValue().ClientURL(), + testServer := DeferTestServer(debug, GinkgoWriter, func() ServeConfiguration { + return ServeConfiguration{ + PostgresConfiguration: PostgresConfiguration(db.GetValue().ConnectionOptions()), + NatsURL: natsServer.GetValue().ClientURL(), } }) BeforeEach(func() { @@ -50,7 +46,7 @@ var _ = Context("Ledger revert transactions API tests", func() { err error ) BeforeEach(func() { - events = Subscribe(GinkgoT(), testServer.GetValue()) + _, events = Subscribe(GinkgoT(), testServer.GetValue()) tx, err = CreateTransaction( ctx, testServer.GetValue(), diff --git a/test/e2e/api_volumes_test.go b/test/e2e/api_volumes_test.go index c7a1be49c1..2a5bcfd951 100644 --- a/test/e2e/api_volumes_test.go +++ b/test/e2e/api_volumes_test.go @@ -31,14 +31,10 @@ var _ = Context("Ledger accounts list API tests", func() { ctx = logging.TestingContext() ) - testServer := NewTestServer(func() Configuration { - return Configuration{ - CommonConfiguration: CommonConfiguration{ - PostgresConfiguration: db.GetValue().ConnectionOptions(), - Output: GinkgoWriter, - Debug: debug, - }, - NatsURL: natsServer.GetValue().ClientURL(), + testServer := DeferTestServer(debug, GinkgoWriter, func() ServeConfiguration { + return ServeConfiguration{ + PostgresConfiguration: PostgresConfiguration(db.GetValue().ConnectionOptions()), + NatsURL: natsServer.GetValue().ClientURL(), } }) diff --git a/test/e2e/app_lifecycle_test.go b/test/e2e/app_lifecycle_test.go index e406cd91dc..deadd80aa2 100644 --- a/test/e2e/app_lifecycle_test.go +++ b/test/e2e/app_lifecycle_test.go @@ -10,6 +10,7 @@ import ( "github.com/formancehq/go-libs/v2/logging" "github.com/formancehq/go-libs/v2/pointer" "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" + "github.com/formancehq/go-libs/v2/testing/testservice" "github.com/formancehq/go-libs/v2/time" ledger "github.com/formancehq/ledger/internal" "github.com/formancehq/ledger/internal/storage" @@ -25,6 +26,7 @@ import ( . "github.com/onsi/gomega" "github.com/uptrace/bun" "math/big" + "net/http" ) var _ = Context("Ledger application lifecycle tests", func() { @@ -34,27 +36,23 @@ var _ = Context("Ledger application lifecycle tests", func() { Context("Pending transaction should be fully processed before stopping or restarting the server", func() { db := UseTemplatedDatabase() - testServer := NewTestServer(func() Configuration { - return Configuration{ - CommonConfiguration: CommonConfiguration{ - PostgresConfiguration: bunconnect.ConnectionOptions{ - DatabaseSourceName: db.GetValue().ConnectionOptions().DatabaseSourceName, - MaxOpenConns: 100, - }, - Output: GinkgoWriter, - Debug: debug, - }, + testServer := DeferTestServer(debug, GinkgoWriter, func() ServeConfiguration { + return ServeConfiguration{ + PostgresConfiguration: PostgresConfiguration(bunconnect.ConnectionOptions{ + DatabaseSourceName: db.GetValue().ConnectionOptions().DatabaseSourceName, + MaxOpenConns: 100, + }), NatsURL: natsServer.GetValue().ClientURL(), } }) var events chan *nats.Msg BeforeEach(func() { - events = Subscribe(GinkgoT(), testServer.GetValue()) + _, events = Subscribe(GinkgoT(), testServer.GetValue()) }) When("starting the service", func() { It("should be ok", func() { - info, err := testServer.GetValue().Client().Ledger.GetInfo(ctx) + info, err := Client(testServer.GetValue()).Ledger.GetInfo(ctx) Expect(err).NotTo(HaveOccurred()) Expect(info.V2ConfigInfoResponse.Version).To(Equal("develop")) }) @@ -80,7 +78,7 @@ var _ = Context("Ledger application lifecycle tests", func() { // lock logs table to block transactions creation requests // the first tx will block on the log insertion // the next transaction will block earlier on advisory lock acquirement for accounts - db := ConnectToDatabase(GinkgoT(), testServer.GetValue()) + db := ConnectToDatabase(ctx, GinkgoT(), testServer.GetValue()) sqlTx, err = db.BeginTx(ctx, &sql.TxOptions{}) Expect(err).To(BeNil()) DeferCleanup(func() { @@ -137,10 +135,11 @@ var _ = Context("Ledger application lifecycle tests", func() { close(restarted) }() By("restart server", func() { - ctx, cancel := context.WithTimeout(ctx, serverRestartTimeout) + stopContext, cancel := context.WithTimeout(ctx, serverRestartTimeout) DeferCleanup(cancel) - Expect(testServer.GetValue().Restart(ctx)).To(BeNil()) + Expect(testServer.GetValue().Stop(stopContext)).To(BeNil()) + Expect(testServer.GetValue().Start(ctx)).To(BeNil()) }) }() @@ -198,15 +197,11 @@ var _ = Context("Ledger application lifecycle tests", func() { Expect(migrator.UpByOne(ctx)).To(BeNil()) } }) - testServer := NewTestServer(func() Configuration { - return Configuration{ - CommonConfiguration: CommonConfiguration{ - PostgresConfiguration: db.GetValue().ConnectionOptions(), - Output: GinkgoWriter, - Debug: debug, - }, - NatsURL: natsServer.GetValue().ClientURL(), - DisableAutoUpgrade: true, + testServer := DeferTestServer(debug, GinkgoWriter, func() ServeConfiguration { + return ServeConfiguration{ + PostgresConfiguration: PostgresConfiguration(db.GetValue().ConnectionOptions()), + NatsURL: natsServer.GetValue().ClientURL(), + DisableAutoUpgrade: true, } }) It("should be ok", func() { @@ -244,14 +239,10 @@ var _ = Context("Ledger downgrade tests", func() { ctx = logging.TestingContext() ) - testServer := NewTestServer(func() Configuration { - return Configuration{ - CommonConfiguration: CommonConfiguration{ - PostgresConfiguration: db.GetValue().ConnectionOptions(), - Output: GinkgoWriter, - Debug: debug, - }, - NatsURL: natsServer.GetValue().ClientURL(), + testServer := DeferTestServer(debug, GinkgoWriter, func() ServeConfiguration { + return ServeConfiguration{ + PostgresConfiguration: PostgresConfiguration(db.GetValue().ConnectionOptions()), + NatsURL: natsServer.GetValue().ClientURL(), } }) @@ -270,7 +261,7 @@ var _ = Context("Ledger downgrade tests", func() { Expect(err).To(BeNil()) // Insert a fake migration into the database to simulate a downgrade - _, err = ConnectToDatabase(GinkgoT(), testServer.GetValue()). + _, err = ConnectToDatabase(ctx, GinkgoT(), testServer.GetValue()). NewInsert(). ModelTableExpr(ledger.DefaultBucket + ".goose_db_version"). Model(&map[string]any{ @@ -288,7 +279,7 @@ var _ = Context("Ledger downgrade tests", func() { }) It("should be ok when targeting health check endpoint", func() { - ret, err := testServer.GetValue().HTTPClient().Get(testServer.GetValue().ServerURL() + "/_healthcheck") + ret, err := http.DefaultClient.Get(testservice.GetServerURL(testServer.GetValue()) + "/_healthcheck") Expect(err).To(BeNil()) body := make(map[string]interface{}) diff --git a/test/e2e/app_logs_blocks_async_test.go b/test/e2e/app_logs_blocks_async_test.go index 04e461a745..ca3d6dafdf 100644 --- a/test/e2e/app_logs_blocks_async_test.go +++ b/test/e2e/app_logs_blocks_async_test.go @@ -28,28 +28,18 @@ var _ = Context("Logs block async hashing", func() { txCount = blockSize * nbBlock ) - testServer := NewTestServer(func() Configuration { - return Configuration{ - CommonConfiguration: CommonConfiguration{ - PostgresConfiguration: db.GetValue().ConnectionOptions(), - Output: GinkgoWriter, - Debug: debug, - }, - NatsURL: natsServer.GetValue().ClientURL(), - ExperimentalFeatures: true, + testServer := DeferTestServer(debug, GinkgoWriter, func() ServeConfiguration { + return ServeConfiguration{ + PostgresConfiguration: PostgresConfiguration(db.GetValue().ConnectionOptions()), + NatsURL: natsServer.GetValue().ClientURL(), + ExperimentalFeatures: true, } }) - NewTestWorker(func() WorkerServiceConfiguration { - return WorkerServiceConfiguration{ - CommonConfiguration: CommonConfiguration{ - PostgresConfiguration: db.GetValue().ConnectionOptions(), - Output: GinkgoWriter, - Debug: debug, - }, - WorkerConfiguration: WorkerConfiguration{ - LogsHashBlockMaxSize: blockSize, - LogsHashBlockCRONSpec: "* * * * * *", // every second - }, + DeferTestWorker(debug, GinkgoWriter, func() WorkerConfiguration { + return WorkerConfiguration{ + PostgresConfiguration: PostgresConfiguration(db.GetValue().ConnectionOptions()), + LogsHashBlockMaxSize: blockSize, + LogsHashBlockCRONSpec: "* * * * * *", // every second } }) JustBeforeEach(func() { @@ -90,11 +80,10 @@ var _ = Context("Logs block async hashing", func() { }) It(fmt.Sprintf("should generate %d blocks", nbBlock), func() { Eventually(func(g Gomega) bool { - db, err := testServer.GetValue().Database() - g.Expect(err).To(BeNil()) + db := ConnectToDatabase(ctx, GinkgoT(), testServer.GetValue()) ret := make([]map[string]any, 0) - err = db.NewSelect(). + err := db.NewSelect(). Model(&ret). ModelTableExpr("_default.logs_blocks"). Scan(ctx) diff --git a/test/e2e/app_multiple_instance_test.go b/test/e2e/app_multiple_instance_test.go index c9b948d2c6..7ec1f8fb5e 100644 --- a/test/e2e/app_multiple_instance_test.go +++ b/test/e2e/app_multiple_instance_test.go @@ -5,6 +5,8 @@ package test_suite import ( "github.com/formancehq/go-libs/v2/logging" "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" + "github.com/formancehq/go-libs/v2/testing/testservice" + "github.com/formancehq/ledger/cmd" . "github.com/formancehq/ledger/pkg/testserver" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -34,15 +36,26 @@ var _ = Context("Ledger application multiple instance tests", func() { // Best effort to start all servers at the same time and detect conflict errors <-waitStart - servers <- New(GinkgoT(), Configuration{ - CommonConfiguration: CommonConfiguration{ - PostgresConfiguration: db.GetValue().ConnectionOptions(), - Output: GinkgoWriter, - Debug: debug, + testServer := testservice.New( + cmd.NewRootCommand, + testservice.Configuration[ServeConfiguration]{ + CommonConfiguration: testservice.CommonConfiguration{ + Debug: debug, + Output: GinkgoWriter, + }, + Configuration: ServeConfiguration{ + PostgresConfiguration: PostgresConfiguration(db.GetValue().ConnectionOptions()), + NatsURL: natsServer.GetValue().ClientURL(), + DisableAutoUpgrade: true, + }, }, - NatsURL: natsServer.GetValue().ClientURL(), - DisableAutoUpgrade: true, - }) + testservice.WithInstruments( + testservice.HTTPServerInstrumentation(), + ), + ) + Expect(testServer.Start(ctx)).To(Succeed()) + + servers <- testServer }() } @@ -57,7 +70,7 @@ var _ = Context("Ledger application multiple instance tests", func() { It("each service should be up and running", func() { for _, server := range allServers { - info, err := server.Client().Ledger.GetInfo(ctx) + info, err := Client(server).Ledger.GetInfo(ctx) Expect(err).NotTo(HaveOccurred()) Expect(info.V2ConfigInfoResponse.Version).To(Equal("develop")) } diff --git a/test/e2e/v1_api_balances_test.go b/test/e2e/v1_api_balances_test.go index a4e2385da7..cc46a96599 100644 --- a/test/e2e/v1_api_balances_test.go +++ b/test/e2e/v1_api_balances_test.go @@ -22,14 +22,10 @@ var _ = Context("Ledger accounts list API tests", func() { ctx = logging.TestingContext() ) - testServer := NewTestServer(func() Configuration { - return Configuration{ - CommonConfiguration: CommonConfiguration{ - PostgresConfiguration: db.GetValue().ConnectionOptions(), - Output: GinkgoWriter, - Debug: debug, - }, - NatsURL: natsServer.GetValue().ClientURL(), + testServer := DeferTestServer(debug, GinkgoWriter, func() ServeConfiguration { + return ServeConfiguration{ + PostgresConfiguration: PostgresConfiguration(db.GetValue().ConnectionOptions()), + NatsURL: natsServer.GetValue().ClientURL(), } }) BeforeEach(func() { @@ -76,7 +72,7 @@ var _ = Context("Ledger accounts list API tests", func() { err error ) BeforeEach(func() { - rsp, err = testServer.GetValue().Client().Ledger.V1.GetBalances( + rsp, err = Client(testServer.GetValue()).Ledger.V1.GetBalances( ctx, operations.GetBalancesRequest{ Ledger: "default", diff --git a/test/performance/pkg/write/local_env_test.go b/test/performance/pkg/write/local_env_test.go index e00a312d07..ca42b38d28 100644 --- a/test/performance/pkg/write/local_env_test.go +++ b/test/performance/pkg/write/local_env_test.go @@ -58,7 +58,7 @@ func (f *TestServerEnvFactory) Create(ctx context.Context, b *testing.B) env.Env output = io.Discard } - testServer := testserver.New(b, testserver.Configuration{ + testServer := testserver.New(b, testserver.ServeConfiguration{ CommonConfiguration: testserver.CommonConfiguration{ PostgresConfiguration: connectionOptions, Debug: os.Getenv("DEBUG") == "true", diff --git a/test/stress/stress_test.go b/test/stress/stress_test.go index 02acef577f..b25b636551 100644 --- a/test/stress/stress_test.go +++ b/test/stress/stress_test.go @@ -27,14 +27,10 @@ var _ = Context("Ledger stress tests", func() { ctx = logging.TestingContext() ) - testServer := NewTestServer(func() Configuration { - return Configuration{ - CommonConfiguration: CommonConfiguration{ - PostgresConfiguration: db.GetValue().ConnectionOptions(), - Output: GinkgoWriter, - Debug: debug, - }, - ExperimentalFeatures: true, + testServer := DeferTestServer(debug, GinkgoWriter, func() ServeConfiguration { + return ServeConfiguration{ + PostgresConfiguration: PostgresConfiguration(db.GetValue().ConnectionOptions()), + ExperimentalFeatures: true, } }) diff --git a/tools/generator/go.mod b/tools/generator/go.mod index accac25bd5..3699cf09e7 100644 --- a/tools/generator/go.mod +++ b/tools/generator/go.mod @@ -1,6 +1,6 @@ module github.com/formancehq/ledger/tools/generator -go 1.23 +go 1.23.0 toolchain go1.23.3 @@ -9,17 +9,17 @@ replace github.com/formancehq/ledger => ../.. replace github.com/formancehq/ledger/pkg/client => ../../pkg/client require ( - github.com/formancehq/go-libs/v2 v2.2.3-0.20250401141012-7ef088564530 + github.com/formancehq/go-libs/v2 v2.2.3-0.20250403104105-55a4f9b367d6 github.com/formancehq/ledger v0.0.0-00010101000000-000000000000 github.com/formancehq/ledger/pkg/client v0.0.0-00010101000000-000000000000 github.com/spf13/cobra v1.9.1 github.com/stretchr/testify v1.10.0 - golang.org/x/oauth2 v0.26.0 + golang.org/x/oauth2 v0.28.0 ) require ( dario.cat/mergo v1.0.1 // indirect - github.com/ThreeDotsLabs/watermill v1.4.4 // indirect + github.com/ThreeDotsLabs/watermill v1.4.6 // indirect github.com/alitto/pond v1.9.2 // indirect github.com/antlr/antlr4/runtime/Go/antlr v1.4.10 // indirect github.com/antlr4-go/antlr/v4 v4.13.1 // indirect @@ -32,7 +32,7 @@ require ( github.com/ericlagergren/decimal v0.0.0-20240411145413-00de7ca16731 // indirect github.com/fatih/color v1.18.0 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect - github.com/formancehq/numscript v0.0.11 // indirect + github.com/formancehq/numscript v0.0.15 // indirect github.com/go-chi/chi/v5 v5.2.1 // indirect github.com/go-logr/logr v1.4.2 // indirect github.com/go-logr/stdr v1.2.2 // indirect @@ -44,7 +44,7 @@ require ( github.com/invopop/jsonschema v0.13.0 // indirect github.com/jackc/pgpassfile v1.0.0 // indirect github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect - github.com/jackc/pgx/v5 v5.7.2 // indirect + github.com/jackc/pgx/v5 v5.7.4 // indirect github.com/jackc/pgxlisten v0.0.0-20241106001234-1d6f6656415c // indirect github.com/jackc/puddle/v2 v2.2.2 // indirect github.com/jinzhu/inflection v1.0.0 // indirect @@ -56,20 +56,20 @@ require ( github.com/oklog/ulid v1.3.1 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect - github.com/puzpuzpuz/xsync/v3 v3.5.0 // indirect + github.com/puzpuzpuz/xsync/v3 v3.5.1 // indirect github.com/sirupsen/logrus v1.9.3 // indirect github.com/spf13/pflag v1.0.6 // indirect github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc // indirect - github.com/uptrace/bun v1.2.9 // indirect + github.com/uptrace/bun v1.2.11 // indirect github.com/uptrace/opentelemetry-go-extra/otellogrus v0.3.2 // indirect github.com/uptrace/opentelemetry-go-extra/otelutil v0.3.2 // indirect github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect github.com/wk8/go-ordered-map/v2 v2.1.9-0.20240816141633-0a40785b4f41 // indirect go.opentelemetry.io/auto/sdk v1.1.0 // indirect - go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.59.0 // indirect + go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.60.0 // indirect go.opentelemetry.io/otel v1.35.0 // indirect - go.opentelemetry.io/otel/log v0.9.0 // indirect + go.opentelemetry.io/otel/log v0.11.0 // indirect go.opentelemetry.io/otel/metric v1.35.0 // indirect go.opentelemetry.io/otel/sdk v1.35.0 // indirect go.opentelemetry.io/otel/trace v1.35.0 // indirect @@ -77,10 +77,10 @@ require ( go.uber.org/fx v1.23.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.0 // indirect - golang.org/x/crypto v0.33.0 // indirect - golang.org/x/exp v0.0.0-20241217172543-b2144cdd0a67 // indirect - golang.org/x/sync v0.11.0 // indirect - golang.org/x/sys v0.30.0 // indirect - golang.org/x/text v0.22.0 // indirect + golang.org/x/crypto v0.36.0 // indirect + golang.org/x/exp v0.0.0-20250305212735-054e65f0b394 // indirect + golang.org/x/sync v0.12.0 // indirect + golang.org/x/sys v0.31.0 // indirect + golang.org/x/text v0.23.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/tools/generator/go.sum b/tools/generator/go.sum index 2046e39582..c38c250a53 100644 --- a/tools/generator/go.sum +++ b/tools/generator/go.sum @@ -12,14 +12,14 @@ github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERo github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 h1:TngWCqHvy9oXAN6lEVMRuU21PR1EtLVZJmdB18Gu3Rw= github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8D7ML55dXQrVaamCz2vxCfdQBasLZfHKk= -github.com/ThreeDotsLabs/watermill v1.4.4 h1:aLClMl6EYIOQy4BML9yb2VpTekbynDatvQbXGp7idCU= -github.com/ThreeDotsLabs/watermill v1.4.4/go.mod h1:lBnrLbxOjeMRgcJbv+UiZr8Ylz8RkJ4m6i/VN/Nk+to= +github.com/ThreeDotsLabs/watermill v1.4.6 h1:rWoXlxdBgUyg/bZ3OO0pON+nESVd9r6tnLTgkZ6CYrU= +github.com/ThreeDotsLabs/watermill v1.4.6/go.mod h1:lBnrLbxOjeMRgcJbv+UiZr8Ylz8RkJ4m6i/VN/Nk+to= github.com/ThreeDotsLabs/watermill-http/v2 v2.3.1 h1:M0iYM5HsGcoxtiQqprRlYZNZnGk3w5LsE9RbC2R8myQ= github.com/ThreeDotsLabs/watermill-http/v2 v2.3.1/go.mod h1:RwGHEzGsEEXC/rQNLWQqR83+WPlABgOgnv2kTB56Y4Y= github.com/ThreeDotsLabs/watermill-kafka/v3 v3.0.6 h1:xK+VLDjYvBrRZDaFZ7WSqiNmZ9lcDG5RIilFVDZOVyQ= github.com/ThreeDotsLabs/watermill-kafka/v3 v3.0.6/go.mod h1:o1GcoF/1CSJ9JSmQzUkULvpZeO635pZe+WWrYNFlJNk= -github.com/ThreeDotsLabs/watermill-nats/v2 v2.1.2 h1:9d7Vb2gepq73Rn/aKaAJWbBiJzS6nDyOm4O353jVsTM= -github.com/ThreeDotsLabs/watermill-nats/v2 v2.1.2/go.mod h1:stjbT+s4u/s5ime5jdIyvPyjBGwGeJewIN7jxH8gp4k= +github.com/ThreeDotsLabs/watermill-nats/v2 v2.1.3 h1:/5IfNugBb9H+BvEHHNRnICmF3jaI9P7wVRzA12kDDDs= +github.com/ThreeDotsLabs/watermill-nats/v2 v2.1.3/go.mod h1:stjbT+s4u/s5ime5jdIyvPyjBGwGeJewIN7jxH8gp4k= github.com/ajg/form v1.5.1 h1:t9c7v8JUKu/XxOGBU0yjNpaMloxGEJhUkqFRq0ibGeU= github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY= github.com/alitto/pond v1.9.2 h1:9Qb75z/scEZVCoSU+osVmQ0I0JOeLfdTDafrbcJ8CLs= @@ -32,10 +32,10 @@ github.com/aws/aws-msk-iam-sasl-signer-go v1.0.1 h1:nMp7diZObd4XEVUR0pEvn7/E13JI github.com/aws/aws-msk-iam-sasl-signer-go v1.0.1/go.mod h1:MVYeeOhILFFemC/XlYTClvBjYZrg/EPd3ts885KrNTI= github.com/aws/aws-sdk-go-v2 v1.36.3 h1:mJoei2CxPutQVxaATCzDUjcZEjVRdpsiiXi2o38yqWM= github.com/aws/aws-sdk-go-v2 v1.36.3/go.mod h1:LLXuLpgzEbD766Z5ECcRmi8AzSwfZItDtmABVkRLGzg= -github.com/aws/aws-sdk-go-v2/config v1.29.9 h1:Kg+fAYNaJeGXp1vmjtidss8O2uXIsXwaRqsQJKXVr+0= -github.com/aws/aws-sdk-go-v2/config v1.29.9/go.mod h1:oU3jj2O53kgOU4TXq/yipt6ryiooYjlkqqVaZk7gY/U= -github.com/aws/aws-sdk-go-v2/credentials v1.17.62 h1:fvtQY3zFzYJ9CfixuAQ96IxDrBajbBWGqjNTCa79ocU= -github.com/aws/aws-sdk-go-v2/credentials v1.17.62/go.mod h1:ElETBxIQqcxej++Cs8GyPBbgMys5DgQPTwo7cUPDKt8= +github.com/aws/aws-sdk-go-v2/config v1.29.12 h1:Y/2a+jLPrPbHpFkpAAYkVEtJmxORlXoo5k2g1fa2sUo= +github.com/aws/aws-sdk-go-v2/config v1.29.12/go.mod h1:xse1YTjmORlb/6fhkWi8qJh3cvZi4JoVNhc+NbJt4kI= +github.com/aws/aws-sdk-go-v2/credentials v1.17.65 h1:q+nV2yYegofO/SUXruT+pn4KxkxmaQ++1B/QedcKBFM= +github.com/aws/aws-sdk-go-v2/credentials v1.17.65/go.mod h1:4zyjAuGOdikpNYiSGpsGz8hLGmUzlY8pc8r9QQ/RXYQ= github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.30 h1:x793wxmUWVDhshP8WW2mlnXuFrO4cOd3HLBroh1paFw= github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.30/go.mod h1:Jpne2tDnYiFascUEs2AWHJL9Yp7A5ZVy3TNyxaAjD6M= github.com/aws/aws-sdk-go-v2/feature/rds/auth v1.5.11 h1:qDk85oQdhwP4NR1RpkN+t40aN46/K96hF9J1vDRrkKM= @@ -50,14 +50,14 @@ github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.3 h1:eAh2A4b github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.3/go.mod h1:0yKJC/kb8sAnmlYa6Zs3QVYqaC8ug2AbnNChv5Ox3uA= github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.15 h1:dM9/92u2F1JbDaGooxTq18wmmFzbJRfXfVfy96/1CXM= github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.15/go.mod h1:SwFBy2vjtA0vZbjjaFtfN045boopadnoVPhu4Fv66vY= -github.com/aws/aws-sdk-go-v2/service/sso v1.25.1 h1:8JdC7Gr9NROg1Rusk25IcZeTO59zLxsKgE0gkh5O6h0= -github.com/aws/aws-sdk-go-v2/service/sso v1.25.1/go.mod h1:qs4a9T5EMLl/Cajiw2TcbNt2UNo/Hqlyp+GiuG4CFDI= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.29.1 h1:KwuLovgQPcdjNMfFt9OhUd9a2OwcOKhxfvF4glTzLuA= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.29.1/go.mod h1:MlYRNmYu/fGPoxBQVvBYr9nyr948aY/WLUvwBMBJubs= +github.com/aws/aws-sdk-go-v2/service/sso v1.25.2 h1:pdgODsAhGo4dvzC3JAG5Ce0PX8kWXrTZGx+jxADD+5E= +github.com/aws/aws-sdk-go-v2/service/sso v1.25.2/go.mod h1:qs4a9T5EMLl/Cajiw2TcbNt2UNo/Hqlyp+GiuG4CFDI= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.30.0 h1:90uX0veLKcdHVfvxhkWUQSCi5VabtwMLFutYiRke4oo= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.30.0/go.mod h1:MlYRNmYu/fGPoxBQVvBYr9nyr948aY/WLUvwBMBJubs= github.com/aws/aws-sdk-go-v2/service/sts v1.33.17 h1:PZV5W8yk4OtH1JAuhV2PXwwO9v5G5Aoj+eMCn4T+1Kc= github.com/aws/aws-sdk-go-v2/service/sts v1.33.17/go.mod h1:cQnB8CUnxbMU82JvlqjKR2HBOm3fe9pWorWBza6MBJ4= -github.com/aws/smithy-go v1.22.2 h1:6D9hW43xKFrRx/tXXfAlIZc4JI+yQe6snnWcQyxSyLQ= -github.com/aws/smithy-go v1.22.2/go.mod h1:irrKGvNn1InZwb2d7fkIRNucdfwR8R+Ts3wxYa/cJHg= +github.com/aws/smithy-go v1.22.3 h1:Z//5NuZCSW6R4PhQ93hShNbyBbn8BWCmCVCt+Q8Io5k= +github.com/aws/smithy-go v1.22.3/go.mod h1:t1ufH5HMublsJYulve2RKmHDC15xu1f26kHCp/HgceI= github.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPnH1Wvgk= github.com/bahlo/generic-list-go v0.2.0/go.mod h1:2KvAjgMlE5NNynlg/5iLrrCCZ2+5xWbdbCW3pNTGyYg= github.com/bluele/gcache v0.0.2 h1:WcbfdXICg7G/DGBh1PFfcirkWOQV+v077yF1pSy3DGw= @@ -102,10 +102,10 @@ github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= -github.com/formancehq/go-libs/v2 v2.2.3-0.20250401141012-7ef088564530 h1:c7loJTPm5e/AwayJIWgZZQAqMIBR/BrClfF5aldDlxE= -github.com/formancehq/go-libs/v2 v2.2.3-0.20250401141012-7ef088564530/go.mod h1:JvBjEDWNf7izCy2dq/eI3aMc9d28gChBe1rjw5yYlAs= -github.com/formancehq/numscript v0.0.11 h1:vZDfRfrhOkuInv5fLIXvWZU3ylK+fVgmR4la01dO5to= -github.com/formancehq/numscript v0.0.11/go.mod h1:btuSv05cYwi9BvLRxVs5zrunU+O1vTgigG1T6UsawcY= +github.com/formancehq/go-libs/v2 v2.2.3-0.20250403104105-55a4f9b367d6 h1:JmplOj1BMlJydMvE5ATVE4diLC+Wgt8rivkSEIocU0A= +github.com/formancehq/go-libs/v2 v2.2.3-0.20250403104105-55a4f9b367d6/go.mod h1:to6sgzwqspeTKlAF0Vdj/13EMHc8oYNc2gJfxf7hrt8= +github.com/formancehq/numscript v0.0.15 h1:dprjzbPWWPvIYM1o9P4Ppb6LKs4UuZw3AYeHy78b06k= +github.com/formancehq/numscript v0.0.15/go.mod h1:P8qnq15PyWUuhskZdsrzTTqVS5CBkhakDKEPAyF4oYQ= github.com/fsnotify/fsnotify v1.8.0 h1:dAwr6QBTBZIkG8roQaJjGof0pp0EeF+tNV7YBP3F/8M= github.com/fsnotify/fsnotify v1.8.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0= github.com/gkampitakis/ciinfo v0.3.0 h1:gWZlOC2+RYYttL0hBqcoQhM7h1qNkVqvRCV1fOvpAv8= @@ -131,16 +131,16 @@ github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE= github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78= github.com/go-sourcemap/sourcemap v2.1.3+incompatible h1:W1iEw64niKVGogNgBN3ePyLFfuisuzeidWPMPWmECqU= github.com/go-sourcemap/sourcemap v2.1.3+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg= -github.com/go-sql-driver/mysql v1.9.0 h1:Y0zIbQXhQKmQgTp44Y1dp3wTXcn804QoTptLZT1vtvo= -github.com/go-sql-driver/mysql v1.9.0/go.mod h1:pDetrLJeA3oMujJuvXc8RJoasr589B6A9fwzD3QMrqw= +github.com/go-sql-driver/mysql v1.9.1 h1:FrjNGn/BsJQjVRuSa8CBrM5BWA9BWoXXat3KrtSb/iI= +github.com/go-sql-driver/mysql v1.9.1/go.mod h1:qn46aNg1333BRMNU69Lq93t8du/dwxI64Gl8i5p1WMU= github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= github.com/go-viper/mapstructure/v2 v2.2.1 h1:ZAaOCxANMuZx5RCeg0mBdEZk7DZasvvZIxtHqx8aGss= github.com/go-viper/mapstructure/v2 v2.2.1/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= -github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/golang/snappy v1.0.0 h1:Oy607GVXHs7RtbggtPBnr2RmDArIsAefDwvrdWvRhGs= +github.com/golang/snappy v1.0.0/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/pprof v0.0.0-20241210010833-40e02aabc2ad h1:a6HEuzUHeKH6hwfN/ZoQgRgVIWFJljSWa/zetS2WTvg= @@ -156,8 +156,8 @@ github.com/gorilla/schema v1.4.1 h1:jUg5hUjCSDZpNGLuXQOgIWGdlgrIdYvgQ0wZtdK1M3E= github.com/gorilla/schema v1.4.1/go.mod h1:Dg5SSm5PV60mhF2NFaTV1xuYYj8tV8NOPRo4FggUMnM= github.com/gorilla/securecookie v1.1.2 h1:YCIWL56dvtr73r6715mJs5ZvhtnY73hBvEF8kXD8ePA= github.com/gorilla/securecookie v1.1.2/go.mod h1:NfCASbcHqRSY+3a8tlWJwsQap2VX5pwzwo4h3eOamfo= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.1 h1:e9Rjr40Z98/clHv5Yg79Is0NtosR5LXRvdr7o/6NwbA= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.1/go.mod h1:tIxuGz/9mpox++sgp9fJjHO0+q1X9/UOWd798aAm22M= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3 h1:5ZPtiqj0JL5oKWmcsq4VMaAW5ukBEgSGXEN89zeH1Jo= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3/go.mod h1:ndYquD05frm2vACXE1nsccT4oJzjhw2arTS2cpUD1PI= github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= @@ -178,8 +178,8 @@ github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsI github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg= github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo= github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM= -github.com/jackc/pgx/v5 v5.7.2 h1:mLoDLV6sonKlvjIEsV56SkWNCnuNv531l94GaIzO+XI= -github.com/jackc/pgx/v5 v5.7.2/go.mod h1:ncY89UGWxg82EykZUwSpUKEfccBGGYq1xjrOpsbsfGQ= +github.com/jackc/pgx/v5 v5.7.4 h1:9wKznZrhWa2QiHL+NjTSPP6yjl3451BX3imWDnokYlg= +github.com/jackc/pgx/v5 v5.7.4/go.mod h1:ncY89UGWxg82EykZUwSpUKEfccBGGYq1xjrOpsbsfGQ= github.com/jackc/pgxlisten v0.0.0-20241106001234-1d6f6656415c h1:bTgmg761ac9Ki27HoLx8IBvc+T+Qj6eptBpKahKIRT4= github.com/jackc/pgxlisten v0.0.0-20241106001234-1d6f6656415c/go.mod h1:N4E1APLOYrbM11HH5kdqAjDa8RJWVwD3JqWpvH22h64= github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo= @@ -196,8 +196,8 @@ github.com/jcmturner/rpc/v2 v2.0.3 h1:7FXXj8Ti1IaVFpSAziCZWNzbNuZmnvw/i6CqLNdWfZ github.com/jcmturner/rpc/v2 v2.0.3/go.mod h1:VUJYCIDm3PVOEHw8sgt091/20OJjskO/YJki3ELg/Hc= github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= -github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc= -github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0= +github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo= +github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -206,8 +206,8 @@ github.com/lithammer/shortuuid/v3 v3.0.7 h1:trX0KTHy4Pbwo/6ia8fscyHoGA+mf1jWbPJV github.com/lithammer/shortuuid/v3 v3.0.7/go.mod h1:vMk8ke37EmiewwolSO1NLW8vP4ZaKlRuDIi8tWWmAts= github.com/logrusorgru/aurora v2.0.3+incompatible h1:tOpm7WcpBTn4fjmVfgpQq0EfczGlG91VSDkswnjF5A8= github.com/logrusorgru/aurora v2.0.3+incompatible/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4= -github.com/lufia/plan9stats v0.0.0-20240909124753-873cd0166683 h1:7UMa6KCCMjZEMDtTVdcGu0B1GmmC7QJKiCCjyTAWQy0= -github.com/lufia/plan9stats v0.0.0-20240909124753-873cd0166683/go.mod h1:ilwx/Dta8jXAgpFYFvSWEMwxmbWXyiUHkd5FwyKhb5k= +github.com/lufia/plan9stats v0.0.0-20250317134145-8bc96cf8fc35 h1:PpXWgLPs+Fqr325bN2FD2ISlRRztXibcX6e8f5FR5Dc= +github.com/lufia/plan9stats v0.0.0-20250317134145-8bc96cf8fc35/go.mod h1:autxFIvghDt3jPTLoqZ9OZ7s9qTGNAWmYCjVFWPX/zg= github.com/mailru/easyjson v0.9.0 h1:PrnmzHw7262yW8sTBwxi1PdJA3Iw/EKBa8psRf7d9a4= github.com/mailru/easyjson v0.9.0/go.mod h1:1+xMtQp2MRNVL/V1bOzuP3aP8VNwRW55fQUto+XFtTU= github.com/maruel/natural v1.1.1 h1:Hja7XhhmvEFhcByqDoHz9QZbkWey+COd9xWfCfn1ioo= @@ -228,10 +228,10 @@ github.com/muhlemmer/gu v0.3.1 h1:7EAqmFrW7n3hETvuAdmFmn4hS8W+z3LgKtrnow+YzNM= github.com/muhlemmer/gu v0.3.1/go.mod h1:YHtHR+gxM+bKEIIs7Hmi9sPT3ZDUvTN/i88wQpZkrdM= github.com/muhlemmer/httpforwarded v0.1.0 h1:x4DLrzXdliq8mprgUMR0olDvHGkou5BJsK/vWUetyzY= github.com/muhlemmer/httpforwarded v0.1.0/go.mod h1:yo9czKedo2pdZhoXe+yDkGVbU0TJ0q9oQ90BVoDEtw0= -github.com/nats-io/nats.go v1.39.1 h1:oTkfKBmz7W047vRxV762M67ZdXeOtUgvbBaNoQ+3PPk= -github.com/nats-io/nats.go v1.39.1/go.mod h1:MgRb8oOdigA6cYpEPhXJuRVH6UE/V4jblJ2jQ27IXYM= -github.com/nats-io/nkeys v0.4.9 h1:qe9Faq2Gxwi6RZnZMXfmGMZkg3afLLOtrU+gDZJ35b0= -github.com/nats-io/nkeys v0.4.9/go.mod h1:jcMqs+FLG+W5YO36OX6wFIFcmpdAns+w1Wm6D3I/evE= +github.com/nats-io/nats.go v1.40.1 h1:MLjDkdsbGUeCMKFyCFoLnNn/HDTqcgVa3EQm+pMNDPk= +github.com/nats-io/nats.go v1.40.1/go.mod h1:wV73x0FSI/orHPSYoyMeJB+KajMDoWyXmFaRrrYaaTo= +github.com/nats-io/nkeys v0.4.10 h1:glmRrpCmYLHByYcePvnTBEAwawwapjCPMjy2huw20wc= +github.com/nats-io/nkeys v0.4.10/go.mod h1:OjRrnIKnWBFl+s4YK5ChQfvHP2fxqZexrKJoVVyWB3U= github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw= github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4= @@ -259,10 +259,10 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRI github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 h1:o4JXh1EVt9k/+g42oCprj/FisM4qX9L3sZB3upGN2ZU= github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE= -github.com/puzpuzpuz/xsync/v3 v3.5.0 h1:i+cMcpEDY1BkNm7lPDkCtE4oElsYLn+EKF8kAu2vXT4= -github.com/puzpuzpuz/xsync/v3 v3.5.0/go.mod h1:VjzYrABPabuM4KyBh1Ftq6u8nhwY5tBPKP9jpmh0nnA= -github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5XpJzTSTfLsJV/mx9Q9g7kxmchpfZyxgzM= -github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= +github.com/puzpuzpuz/xsync/v3 v3.5.1 h1:GJYJZwO6IdxN/IKbneznS6yPkVC+c3zyY/j19c++5Fg= +github.com/puzpuzpuz/xsync/v3 v3.5.1/go.mod h1:VjzYrABPabuM4KyBh1Ftq6u8nhwY5tBPKP9jpmh0nnA= +github.com/rcrowley/go-metrics v0.0.0-20250401214520-65e299d6c5c9 h1:bsUq1dX0N8AOIL7EB/X911+m4EHsnWEHeJ0c+3TTBrg= +github.com/rcrowley/go-metrics v0.0.0-20250401214520-65e299d6c5c9/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/riandyrn/otelchi v0.12.1 h1:FdRKK3/RgZ/T+d+qTH5Uw3MFx0KwRF38SkdfTMMq/m8= github.com/riandyrn/otelchi v0.12.1/go.mod h1:weZZeUJURvtCcbWsdb7Y6F8KFZGedJlSrgUjq9VirV8= github.com/robfig/cron v1.2.0 h1:ZjScXvvxeQ63Dbyxy76Fj3AT3Ut0aKsyd2/tl3DTMuQ= @@ -273,10 +273,10 @@ github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWN github.com/rs/cors v1.11.1 h1:eU3gRzXLRK57F5rKMGMZURNdIG4EoAmX8k94r9wXWHA= github.com/rs/cors v1.11.1/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/sagikazarmark/locafero v0.7.0 h1:5MqpDsTGNDhY8sGp0Aowyf0qKsPrhewaLSsFaodPcyo= -github.com/sagikazarmark/locafero v0.7.0/go.mod h1:2za3Cg5rMaTMoG/2Ulr9AwtFaIppKXTRYnozin4aB5k= -github.com/shirou/gopsutil/v4 v4.24.12 h1:qvePBOk20e0IKA1QXrIIU+jmk+zEiYVVx06WjBRlZo4= -github.com/shirou/gopsutil/v4 v4.24.12/go.mod h1:DCtMPAad2XceTeIAbGyVfycbYQNBGk2P8cvDi7/VN9o= +github.com/sagikazarmark/locafero v0.9.0 h1:GbgQGNtTrEmddYDSAH9QLRyfAHY12md+8YFTqyMTC9k= +github.com/sagikazarmark/locafero v0.9.0/go.mod h1:UBUyz37V+EdMS3hDF3QWIiVr/2dPrx49OMO0Bn0hJqk= +github.com/shirou/gopsutil/v4 v4.25.3 h1:SeA68lsu8gLggyMbmCn8cmp97V1TI9ld9sVzAUcKcKE= +github.com/shirou/gopsutil/v4 v4.25.3/go.mod h1:xbuxyoZj+UsgnZrENu3lQivsngRR5BdjbJwf2fv4szA= github.com/shomali11/util v0.0.0-20220717175126-f0771b70947f h1:OM0LVaVycWC+/j5Qra7USyCg2sc+shg3KwygAA+pYvA= github.com/shomali11/util v0.0.0-20220717175126-f0771b70947f/go.mod h1:9POpw/crb6YrseaYBOwraL0lAYy0aOW79eU3bvMxgbM= github.com/shomali11/xsql v0.0.0-20190608141458-bf76292144df h1:SVCDTuzM3KEk8WBwSSw7RTPLw9ajzBaXDg39Bo6xIeU= @@ -285,16 +285,16 @@ github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo= github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0= -github.com/spf13/afero v1.12.0 h1:UcOPyRBYczmFn6yvphxkn9ZEOY65cpwGKb5mL36mrqs= -github.com/spf13/afero v1.12.0/go.mod h1:ZTlWwG4/ahT8W7T0WQ5uYmjI9duaLQGy3Q2OAl4sk/4= +github.com/spf13/afero v1.14.0 h1:9tH6MapGnn/j0eb0yIXiLjERO8RB6xIVZRDCX7PtqWA= +github.com/spf13/afero v1.14.0/go.mod h1:acJQ8t0ohCGuMN3O+Pv0V0hgMxNYDlvdk+VTfyZmbYo= github.com/spf13/cast v1.7.1 h1:cuNEagBQEHWN1FnbGEjCXL2szYEXqfJPbP2HNUaca9Y= github.com/spf13/cast v1.7.1/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo= github.com/spf13/cobra v1.9.1 h1:CXSaggrXdbHK9CF+8ywj8Amf7PBRmPCOJugH954Nnlo= github.com/spf13/cobra v1.9.1/go.mod h1:nDyEzZ8ogv936Cinf6g1RU9MRY64Ir93oCnqb9wxYW0= github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o= github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= -github.com/spf13/viper v1.20.0 h1:zrxIyR3RQIOsarIrgL8+sAvALXul9jeEPa06Y0Ph6vY= -github.com/spf13/viper v1.20.0/go.mod h1:P9Mdzt1zoHIG8m2eZQinpiBjo6kCmZSKBClNNqjJvu4= +github.com/spf13/viper v1.20.1 h1:ZMi+z/lvLyPSCoNtFCpqjy0S4kPbirhpTMwl8BkW9X4= +github.com/spf13/viper v1.20.1/go.mod h1:P9Mdzt1zoHIG8m2eZQinpiBjo6kCmZSKBClNNqjJvu4= github.com/stoewer/go-strcase v1.3.0 h1:g0eASXYtp+yvN9fK8sH94oCIk0fau9uV1/ZdJ0AVEzs= github.com/stoewer/go-strcase v1.3.0/go.mod h1:fAH5hQ5pehh+j3nZfvwdk2RgEgQjAoM8wodgtPmh1xo= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -313,20 +313,20 @@ github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY= github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28= -github.com/tklauser/go-sysconf v0.3.14 h1:g5vzr9iPFFz24v2KZXs/pvpvh8/V9Fw6vQK5ZZb78yU= -github.com/tklauser/go-sysconf v0.3.14/go.mod h1:1ym4lWMLUOhuBOPGtRcJm7tEGX4SCYNEEEtghGG/8uY= -github.com/tklauser/numcpus v0.9.0 h1:lmyCHtANi8aRUgkckBgoDk1nHCux3n2cgkJLXdQGPDo= -github.com/tklauser/numcpus v0.9.0/go.mod h1:SN6Nq1O3VychhC1npsWostA+oW+VOQTxZrS604NSRyI= +github.com/tklauser/go-sysconf v0.3.15 h1:VE89k0criAymJ/Os65CSn1IXaol+1wrsFHEB8Ol49K4= +github.com/tklauser/go-sysconf v0.3.15/go.mod h1:Dmjwr6tYFIseJw7a3dRLJfsHAMXZ3nEnL/aZY+0IuI4= +github.com/tklauser/numcpus v0.10.0 h1:18njr6LDBk1zuna922MgdjQuJFjrdppsZG60sHGfjso= +github.com/tklauser/numcpus v0.10.0/go.mod h1:BiTKazU708GQTYF4mB+cmlpT2Is1gLk7XVuEeem8LsQ= github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc h1:9lRDQMhESg+zvGYmW5DyG0UqvY96Bu5QYsTLvCHdrgo= github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc/go.mod h1:bciPuU6GHm1iF1pBvUfxfsH0Wmnc2VbpgvbI9ZWuIRs= -github.com/uptrace/bun v1.2.9 h1:OOt2DlIcRUMSZPr6iXDFg/LaQd59kOxbAjpIVHddKRs= -github.com/uptrace/bun v1.2.9/go.mod h1:r2ZaaGs9Ru5bpGTr8GQfp8jp+TlCav9grYCPOu2CJSg= -github.com/uptrace/bun/dialect/pgdialect v1.2.9 h1:caf5uFbOGiXvadV6pA5gn87k0awFFxL1kuuY3SpxnWk= -github.com/uptrace/bun/dialect/pgdialect v1.2.9/go.mod h1:m7L9JtOp/Lt8HccET70ULxplMweE/u0S9lNUSxz2duo= +github.com/uptrace/bun v1.2.11 h1:l9dTymsdZZAoSZ1+Qo3utms0RffgkDbIv+1UGk8N1wQ= +github.com/uptrace/bun v1.2.11/go.mod h1:ww5G8h59UrOnCHmZ8O1I/4Djc7M/Z3E+EWFS2KLB6dQ= +github.com/uptrace/bun/dialect/pgdialect v1.2.11 h1:n0VKWm1fL1dwJK5TRxYYLaRKRe14BOg2+AQgpvqzG/M= +github.com/uptrace/bun/dialect/pgdialect v1.2.11/go.mod h1:NvV1S/zwtwBnW8yhJ3XEKAQEw76SkeH7yUhfrx3W1Eo= github.com/uptrace/bun/extra/bundebug v1.2.9 h1:3SU66p+q76XhfeUUzl9XooVu7hVNueZ/2Q3J8S1uzCU= github.com/uptrace/bun/extra/bundebug v1.2.9/go.mod h1:/rp83jYAtwZUQIz+L3KwvREXaSd5GQGPJUusqq+Qtis= -github.com/uptrace/bun/extra/bunotel v1.2.9 h1:BGGrBga+iVL78SGiMpLt2N9MAKvrG3f8wLk8zCLwFJg= -github.com/uptrace/bun/extra/bunotel v1.2.9/go.mod h1:6dVl5Ko6xOhuoqUPWHpfFrntBDwmOnq0OMiR/SGwAC8= +github.com/uptrace/bun/extra/bunotel v1.2.11 h1:ddt96XrbvlVZu5vBddP6WmbD6bdeJTaWY9jXlfuJKZE= +github.com/uptrace/bun/extra/bunotel v1.2.11/go.mod h1:w6Mhie5tLFeP+5ryjq4PvgZEESRJ1iL2cbvxhm+f8q4= github.com/uptrace/opentelemetry-go-extra/otellogrus v0.3.2 h1:H8wwQwTe5sL6x30z71lUgNiwBdeCHQjrphCfLwqIHGo= github.com/uptrace/opentelemetry-go-extra/otellogrus v0.3.2/go.mod h1:/kR4beFhlz2g+V5ik8jW+3PMiMQAPt29y6K64NNY53c= github.com/uptrace/opentelemetry-go-extra/otelsql v0.3.2 h1:ZjUj9BLYf9PEqBn8W/OapxhPjVRdC6CsXTdULHsyk5c= @@ -351,22 +351,22 @@ github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHo github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74= github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= -github.com/xo/dburl v0.23.3 h1:s9tUyKAkcgRfNQ7ut5gaDWC9s5ROafY3hmNOrGbNXtE= -github.com/xo/dburl v0.23.3/go.mod h1:uazlaAQxj4gkshhfuuYyvwCBouOmNnG2aDxTCFZpmL4= +github.com/xo/dburl v0.23.4 h1:VLI0JT+w95uDiGhCYqbuLTM3gkfg5ODiSoegiEZpcVg= +github.com/xo/dburl v0.23.4/go.mod h1:uazlaAQxj4gkshhfuuYyvwCBouOmNnG2aDxTCFZpmL4= github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0= github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= github.com/zitadel/oidc/v2 v2.12.2 h1:3kpckg4rurgw7w7aLJrq7yvRxb2pkNOtD08RH42vPEs= github.com/zitadel/oidc/v2 v2.12.2/go.mod h1:vhP26g1g4YVntcTi0amMYW3tJuid70nxqxf+kb6XKgg= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= -go.opentelemetry.io/contrib/instrumentation/host v0.59.0 h1:MxVp+9mvrp4FP17hT5BEwMRyk8SDv6kCEq123g5kECE= -go.opentelemetry.io/contrib/instrumentation/host v0.59.0/go.mod h1:5w9UOUSe2M2HMJOWKXX1YjcZIiDbXDu0DkOUQ/nTGS4= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.59.0 h1:CV7UdSGJt/Ao6Gp4CXckLxVRRsRgDHoI8XjbL3PDl8s= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.59.0/go.mod h1:FRmFuRJfag1IZ2dPkHnEoSFVgTVPUd2qf5Vi69hLb8I= -go.opentelemetry.io/contrib/instrumentation/runtime v0.59.0 h1:rfi2MMujBc4yowE0iHckZX4o4jg6SA67EnFVL8ldVvU= -go.opentelemetry.io/contrib/instrumentation/runtime v0.59.0/go.mod h1:IO/gfPEcQYpOpPxn1OXFp1DvRY0viP8ONMedXLjjHIU= -go.opentelemetry.io/contrib/propagators/b3 v1.34.0 h1:9pQdCEvV/6RWQmag94D6rhU+A4rzUhYBEJ8bpscx5p8= -go.opentelemetry.io/contrib/propagators/b3 v1.34.0/go.mod h1:FwM71WS8i1/mAK4n48t0KU6qUS/OZRBgDrHZv3RlJ+w= +go.opentelemetry.io/contrib/instrumentation/host v0.60.0 h1:LD6TMRg2hfNzkMD36Pq0jeYBcSP9W0aJt41Zmje43Ig= +go.opentelemetry.io/contrib/instrumentation/host v0.60.0/go.mod h1:GN4xnih1u2OQeRs8rNJ13XR8XsTqFopc57e/3Kf0h6c= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.60.0 h1:sbiXRNDSWJOTobXh5HyQKjq6wUC5tNybqjIqDpAY4CU= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.60.0/go.mod h1:69uWxva0WgAA/4bu2Yy70SLDBwZXuQ6PbBpbsa5iZrQ= +go.opentelemetry.io/contrib/instrumentation/runtime v0.60.0 h1:0NgN/3SYkqYJ9NBlDfl/2lzVlwos/YQLvi8sUrzJRBE= +go.opentelemetry.io/contrib/instrumentation/runtime v0.60.0/go.mod h1:oxpUfhTkhgQaYIjtBt3T3w135dLoxq//qo3WPlPIKkE= +go.opentelemetry.io/contrib/propagators/b3 v1.35.0 h1:DpwKW04LkdFRFCIgM3sqwTJA/QREHMeMHYPWP1WeaPQ= +go.opentelemetry.io/contrib/propagators/b3 v1.35.0/go.mod h1:9+SNxwqvCWo1qQwUpACBY5YKNVxFJn5mlbXg/4+uKBg= go.opentelemetry.io/otel v1.35.0 h1:xKWKPxrxB6OtMCbmMY021CqC45J+3Onta9MqjhnusiQ= go.opentelemetry.io/otel v1.35.0/go.mod h1:UEqy8Zp11hpkUrL73gSlELM0DupHoiq72dR+Zqel/+Y= go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.35.0 h1:QcFwRrZLc82r8wODjvyCbP7Ifp3UANaBSmhDSFjnqSc= @@ -383,8 +383,8 @@ go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v1.35.0 h1:PB3Zrjs1sG1GBX go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v1.35.0/go.mod h1:U2R3XyVPzn0WX7wOIypPuptulsMcPDPs/oiSVOMVnHY= go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.35.0 h1:T0Ec2E+3YZf5bgTNQVet8iTDW7oIk03tXHq+wkwIDnE= go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.35.0/go.mod h1:30v2gqH+vYGJsesLWFov8u47EpYTcIQcBjKpI6pJThg= -go.opentelemetry.io/otel/log v0.9.0 h1:0OiWRefqJ2QszpCiqwGO0u9ajMPe17q6IscQvvp3czY= -go.opentelemetry.io/otel/log v0.9.0/go.mod h1:WPP4OJ+RBkQ416jrFCQFuFKtXKD6mOoYCQm6ykK8VaU= +go.opentelemetry.io/otel/log v0.11.0 h1:c24Hrlk5WJ8JWcwbQxdBqxZdOK7PcP/LFtOtwpDTe3Y= +go.opentelemetry.io/otel/log v0.11.0/go.mod h1:U/sxQ83FPmT29trrifhQg+Zj2lo1/IPN1PF6RTFqdwc= go.opentelemetry.io/otel/metric v1.35.0 h1:0znxYu2SNyuMSQT4Y9WDWej0VpcsxkuklLa4/siN90M= go.opentelemetry.io/otel/metric v1.35.0/go.mod h1:nKVFgxBZ2fReX6IlyW28MgZojkoAkJGaE8CpgeAU3oE= go.opentelemetry.io/otel/sdk v1.35.0 h1:iPctf8iprVySXSKJffSS79eOjl9pvxV9ZqOWT0QejKY= @@ -407,16 +407,16 @@ go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= -golang.org/x/crypto v0.33.0 h1:IOBPskki6Lysi0lo9qQvbxiQ+FvsCC/YWOecCHAixus= -golang.org/x/crypto v0.33.0/go.mod h1:bVdXmD7IV/4GdElGPozy6U7lWdRXA4qyRVGJV57uQ5M= -golang.org/x/exp v0.0.0-20241217172543-b2144cdd0a67 h1:1UoZQm6f0P/ZO0w1Ri+f+ifG/gXhegadRdwBIXEFWDo= -golang.org/x/exp v0.0.0-20241217172543-b2144cdd0a67/go.mod h1:qj5a5QZpwLU2NLQudwIN5koi3beDhSAlJwa67PuM98c= -golang.org/x/net v0.35.0 h1:T5GQRQb2y08kTAByq9L4/bz8cipCdA8FbRTXewonqY8= -golang.org/x/net v0.35.0/go.mod h1:EglIi67kWsHKlRzzVMUD93VMSWGFOMSZgxFjparz1Qk= -golang.org/x/oauth2 v0.26.0 h1:afQXWNNaeC4nvZ0Ed9XvCCzXM6UHJG7iCg0W4fPqSBE= -golang.org/x/oauth2 v0.26.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= -golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w= -golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34= +golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc= +golang.org/x/exp v0.0.0-20250305212735-054e65f0b394 h1:nDVHiLt8aIbd/VzvPWN6kSOPE7+F/fNFDSXLVYkE/Iw= +golang.org/x/exp v0.0.0-20250305212735-054e65f0b394/go.mod h1:sIifuuw/Yco/y6yb6+bDNfyeQ/MdPUy/hKEMYQV17cM= +golang.org/x/net v0.38.0 h1:vRMAPTMaeGqVhG5QyLJHqNDwecKTomGeqbnfZyKlBI8= +golang.org/x/net v0.38.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8= +golang.org/x/oauth2 v0.28.0 h1:CrgCKl8PPAVtLnU3c+EDw6x11699EWlsDeWNWKdIOkc= +golang.org/x/oauth2 v0.28.0/go.mod h1:onh5ek6nERTohokkhCD/y2cV4Do3fxFHFuAejCkRWT8= +golang.org/x/sync v0.12.0 h1:MHc5BpPuC30uJk597Ri8TV3CNZcTLu6B6z4lJy+g6Jw= +golang.org/x/sync v0.12.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -424,20 +424,20 @@ golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc= -golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM= -golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY= -golang.org/x/tools v0.30.0 h1:BgcpHewrV5AUp2G9MebG4XPFI1E2W41zU1SaqVA9vJY= -golang.org/x/tools v0.30.0/go.mod h1:c347cR/OJfw5TI+GfX7RUPNMdDRRbjvYTS0jPyvsVtY= -google.golang.org/genproto/googleapis/api v0.0.0-20250218202821-56aae31c358a h1:nwKuGPlUAt+aR+pcrkfFRrTU1BVrSmYyYMxYbUIVHr0= -google.golang.org/genproto/googleapis/api v0.0.0-20250218202821-56aae31c358a/go.mod h1:3kWAYMk1I75K4vykHtKt2ycnOgpA6974V7bREqbsenU= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a h1:51aaUVRocpvUOSQKM6Q7VuoaktNIaMCLuhZB6DKksq4= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a/go.mod h1:uRxBH1mhmO8PGhU89cMcHaXKZqO+OfakD8QQO0oYwlQ= -google.golang.org/grpc v1.71.0 h1:kF77BGdPTQ4/JZWMlb9VpJ5pa25aqvVqogsxNHHdeBg= -google.golang.org/grpc v1.71.0/go.mod h1:H0GRtasmQOh9LkFoCPDu3ZrwUtD1YGE+b2vYBYd/8Ec= -google.golang.org/protobuf v1.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwlM= -google.golang.org/protobuf v1.36.5/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= +golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik= +golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= +golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY= +golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4= +golang.org/x/tools v0.31.0 h1:0EedkvKDbh+qistFTd0Bcwe/YLh4vHwWEkiI0toFIBU= +golang.org/x/tools v0.31.0/go.mod h1:naFTU+Cev749tSJRXJlna0T3WxKvb1kWEx15xA4SdmQ= +google.golang.org/genproto/googleapis/api v0.0.0-20250324211829-b45e905df463 h1:hE3bRWtU6uceqlh4fhrSnUyjKHMKB9KrTLLG+bc0ddM= +google.golang.org/genproto/googleapis/api v0.0.0-20250324211829-b45e905df463/go.mod h1:U90ffi8eUL9MwPcrJylN5+Mk2v3vuPDptd5yyNUiRR8= +google.golang.org/genproto/googleapis/rpc v0.0.0-20250324211829-b45e905df463 h1:e0AIkUUhxyBKh6ssZNrAMeqhA7RKUj42346d1y02i2g= +google.golang.org/genproto/googleapis/rpc v0.0.0-20250324211829-b45e905df463/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= +google.golang.org/grpc v1.71.1 h1:ffsFWr7ygTUscGPI0KKK6TLrGz0476KUvvsbqWK0rPI= +google.golang.org/grpc v1.71.1/go.mod h1:H0GRtasmQOh9LkFoCPDu3ZrwUtD1YGE+b2vYBYd/8Ec= +google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY= +google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= From a8720d0acd8a2abdc355e1d4b3f7dbcfcf841e65 Mon Sep 17 00:00:00 2001 From: Geoffrey Ragot Date: Thu, 3 Apr 2025 16:14:39 +0200 Subject: [PATCH 2/4] feat: use instrumentations --- go.mod | 4 +- go.sum | 8 +- internal/storage/ledger/main_test.go | 15 +-- pkg/generate/generator_test.go | 20 ++-- pkg/testserver/api.go | 53 +++++----- pkg/testserver/client.go | 4 +- pkg/testserver/helpers.go | 14 +-- pkg/testserver/matchers.go | 5 +- pkg/testserver/server.go | 99 ++++--------------- pkg/testserver/utils.go | 60 +++++------ pkg/testserver/worker.go | 26 ++--- test/e2e/api_accounts_list_test.go | 20 ++-- test/e2e/api_accounts_metadata_test.go | 22 +++-- test/e2e/api_balances_aggregated_test.go | 17 ++-- test/e2e/api_bulk_test.go | 25 +++-- test/e2e/api_ledgers_create_test.go | 27 +++-- test/e2e/api_ledgers_import_test.go | 27 +++-- test/e2e/api_ledgers_list_test.go | 23 +++-- test/e2e/api_ledgers_metadata_test.go | 18 ++-- test/e2e/api_logs_list_test.go | 18 ++-- test/e2e/api_transactions_create_test.go | 31 ++++-- test/e2e/api_transactions_list_test.go | 18 ++-- test/e2e/api_transactions_metadata_test.go | 18 ++-- test/e2e/api_transactions_revert_test.go | 23 +++-- test/e2e/api_volumes_test.go | 17 ++-- test/e2e/app_lifecycle_test.go | 67 ++++++++----- test/e2e/app_logs_blocks_async_test.go | 40 ++++---- test/e2e/app_multiple_instance_test.go | 20 ++-- test/e2e/suite_test.go | 25 ++--- test/e2e/v1_api_balances_test.go | 17 ++-- test/performance/pkg/env/env.go | 1 - test/performance/pkg/env/env_remote_ledger.go | 16 +-- test/performance/pkg/write/local_env_test.go | 31 +++--- test/stress/stress_test.go | 14 +-- test/stress/suite_test.go | 14 +-- tools/generator/go.mod | 2 +- tools/generator/go.sum | 8 +- 37 files changed, 460 insertions(+), 407 deletions(-) diff --git a/go.mod b/go.mod index 83ce70ecfa..5e9d39aa74 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/antlr/antlr4/runtime/Go/antlr v1.4.10 github.com/bluele/gcache v0.0.2 github.com/dop251/goja v0.0.0-20241009100908-5f46f2705ca3 - github.com/formancehq/go-libs/v2 v2.2.3-0.20250403104105-55a4f9b367d6 + github.com/formancehq/go-libs/v2 v2.2.3-0.20250404084034-ca6bcdb75003 github.com/formancehq/ledger/pkg/client v0.0.0-00010101000000-000000000000 github.com/go-chi/chi/v5 v5.2.1 github.com/go-chi/cors v1.2.1 @@ -24,7 +24,7 @@ require ( github.com/jackc/pgx/v5 v5.7.4 github.com/jamiealquiza/tachymeter v2.0.0+incompatible github.com/logrusorgru/aurora v2.0.3+incompatible - github.com/nats-io/nats.go v1.40.1 + github.com/nats-io/nats.go v1.41.0 github.com/onsi/ginkgo/v2 v2.22.1 github.com/onsi/gomega v1.36.2 github.com/ory/dockertest/v3 v3.11.0 diff --git a/go.sum b/go.sum index 4c9ca11ca5..7eae14b91f 100644 --- a/go.sum +++ b/go.sum @@ -104,8 +104,8 @@ github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= -github.com/formancehq/go-libs/v2 v2.2.3-0.20250403104105-55a4f9b367d6 h1:JmplOj1BMlJydMvE5ATVE4diLC+Wgt8rivkSEIocU0A= -github.com/formancehq/go-libs/v2 v2.2.3-0.20250403104105-55a4f9b367d6/go.mod h1:to6sgzwqspeTKlAF0Vdj/13EMHc8oYNc2gJfxf7hrt8= +github.com/formancehq/go-libs/v2 v2.2.3-0.20250404084034-ca6bcdb75003 h1:GEhD0mORxEGa9in2R/AKRLqubsdXYTjaxnNFEtT10FQ= +github.com/formancehq/go-libs/v2 v2.2.3-0.20250404084034-ca6bcdb75003/go.mod h1:to6sgzwqspeTKlAF0Vdj/13EMHc8oYNc2gJfxf7hrt8= github.com/formancehq/numscript v0.0.15 h1:dprjzbPWWPvIYM1o9P4Ppb6LKs4UuZw3AYeHy78b06k= github.com/formancehq/numscript v0.0.15/go.mod h1:P8qnq15PyWUuhskZdsrzTTqVS5CBkhakDKEPAyF4oYQ= github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= @@ -262,8 +262,8 @@ github.com/nats-io/jwt/v2 v2.7.3 h1:6bNPK+FXgBeAqdj4cYQ0F8ViHRbi7woQLq4W29nUAzE= github.com/nats-io/jwt/v2 v2.7.3/go.mod h1:GvkcbHhKquj3pkioy5put1wvPxs78UlZ7D/pY+BgZk4= github.com/nats-io/nats-server/v2 v2.10.25 h1:J0GWLDDXo5HId7ti/lTmBfs+lzhmu8RPkoKl0eSCqwc= github.com/nats-io/nats-server/v2 v2.10.25/go.mod h1:/YYYQO7cuoOBt+A7/8cVjuhWTaTUEAlZbJT+3sMAfFU= -github.com/nats-io/nats.go v1.40.1 h1:MLjDkdsbGUeCMKFyCFoLnNn/HDTqcgVa3EQm+pMNDPk= -github.com/nats-io/nats.go v1.40.1/go.mod h1:wV73x0FSI/orHPSYoyMeJB+KajMDoWyXmFaRrrYaaTo= +github.com/nats-io/nats.go v1.41.0 h1:PzxEva7fflkd+n87OtQTXqCTyLfIIMFJBpyccHLE2Ko= +github.com/nats-io/nats.go v1.41.0/go.mod h1:wV73x0FSI/orHPSYoyMeJB+KajMDoWyXmFaRrrYaaTo= github.com/nats-io/nkeys v0.4.10 h1:glmRrpCmYLHByYcePvnTBEAwawwapjCPMjy2huw20wc= github.com/nats-io/nkeys v0.4.10/go.mod h1:OjRrnIKnWBFl+s4YK5ChQfvHP2fxqZexrKJoVVyWB3U= github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw= diff --git a/internal/storage/ledger/main_test.go b/internal/storage/ledger/main_test.go index f4045258da..b787f52608 100644 --- a/internal/storage/ledger/main_test.go +++ b/internal/storage/ledger/main_test.go @@ -5,6 +5,7 @@ package ledger_test import ( "database/sql" "github.com/formancehq/go-libs/v2/bun/bundebug" + "github.com/formancehq/go-libs/v2/testing/deferred" . "github.com/formancehq/go-libs/v2/testing/utils" "github.com/formancehq/ledger/internal/storage/bucket" "github.com/formancehq/ledger/internal/storage/driver" @@ -29,19 +30,19 @@ import ( ) var ( - srv = NewDeferred[*pgtesting.PostgresServer]() - defaultBunDB = NewDeferred[*bun.DB]() - defaultDriver = NewDeferred[*driver.Driver]() + srv = deferred.New[*pgtesting.PostgresServer]() + defaultBunDB = deferred.New[*bun.DB]() + defaultDriver = deferred.New[*driver.Driver]() ) func TestMain(m *testing.M) { WithTestMain(func(t *TestingTForMain) int { - srv.LoadAsync(func() *pgtesting.PostgresServer { + srv.LoadAsync(func() (*pgtesting.PostgresServer, error) { ret := pgtesting.CreatePostgresServer(t, docker.NewPool(t, logging.Testing()), pgtesting.WithExtension("pgcrypto"), ) - defaultBunDB.LoadAsync(func() *bun.DB { + defaultBunDB.LoadAsync(func() (*bun.DB, error) { db, err := sql.Open("pgx", ret.GetDSN()) require.NoError(t, err) @@ -63,9 +64,9 @@ func TestMain(m *testing.M) { systemstore.NewStoreFactory(), )) - return bunDB + return bunDB, nil }) - return ret + return ret, nil }) return m.Run() diff --git a/pkg/generate/generator_test.go b/pkg/generate/generator_test.go index 20e6c53493..f805663bb1 100644 --- a/pkg/generate/generator_test.go +++ b/pkg/generate/generator_test.go @@ -5,6 +5,7 @@ package generate import ( "github.com/formancehq/go-libs/v2/bun/bunconnect" "github.com/formancehq/go-libs/v2/logging" + "github.com/formancehq/go-libs/v2/testing/deferred" "github.com/formancehq/go-libs/v2/testing/docker" "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" "github.com/formancehq/go-libs/v2/testing/testservice" @@ -21,16 +22,15 @@ func TestGenerator(t *testing.T) { pgServer := pgtesting.CreatePostgresServer(t, dockerPool) ctx := logging.TestingContext() - testServer := NewTestServer(testservice.Configuration[ServeConfiguration]{ - CommonConfiguration: testservice.CommonConfiguration{ - Debug: os.Getenv("DEBUG") == "true", - }, - Configuration: ServeConfiguration{ - PostgresConfiguration: PostgresConfiguration(bunconnect.ConnectionOptions{ - DatabaseSourceName: pgServer.GetDSN(), - }), - }, - }, testservice.WithLogger(t)) + testServer := NewTestServer( + deferred.FromValue(bunconnect.ConnectionOptions{ + DatabaseSourceName: pgServer.GetDSN(), + }), + testservice.WithLogger(t), + testservice.WithInstruments( + testservice.DebugInstrumentation(os.Getenv("DEBUG") == "true"), + ), + ) require.NoError(t, testServer.Start(ctx)) t.Cleanup(func() { require.NoError(t, testServer.Stop(ctx)) diff --git a/pkg/testserver/api.go b/pkg/testserver/api.go index dd117fc47c..8ef2a5dfd5 100644 --- a/pkg/testserver/api.go +++ b/pkg/testserver/api.go @@ -3,6 +3,7 @@ package testserver import ( "bytes" "context" + "github.com/formancehq/go-libs/v2/testing/testservice" "io" "math/big" "strconv" @@ -13,12 +14,12 @@ import ( "github.com/formancehq/ledger/pkg/client/models/sdkerrors" ) -func CreateLedger(ctx context.Context, srv *Server, request operations.V2CreateLedgerRequest) error { +func CreateLedger(ctx context.Context, srv *testservice.Service, request operations.V2CreateLedgerRequest) error { _, err := Client(srv).Ledger.V2.CreateLedger(ctx, request) return mapSDKError(err) } -func GetLedger(ctx context.Context, srv *Server, request operations.V2GetLedgerRequest) (*components.V2Ledger, error) { +func GetLedger(ctx context.Context, srv *testservice.Service, request operations.V2GetLedgerRequest) (*components.V2Ledger, error) { ret, err := Client(srv).Ledger.V2.GetLedger(ctx, request) if err := mapSDKError(err); err != nil { return nil, err @@ -26,15 +27,15 @@ func GetLedger(ctx context.Context, srv *Server, request operations.V2GetLedgerR return &ret.V2GetLedgerResponse.Data, nil } -func GetInfo(ctx context.Context, srv *Server) (*operations.V2GetInfoResponse, error) { +func GetInfo(ctx context.Context, srv *testservice.Service) (*operations.V2GetInfoResponse, error) { return Client(srv).Ledger.GetInfo(ctx) } -func GetLedgerInfo(ctx context.Context, srv *Server, request operations.V2GetLedgerInfoRequest) (*operations.V2GetLedgerInfoResponse, error) { +func GetLedgerInfo(ctx context.Context, srv *testservice.Service, request operations.V2GetLedgerInfoRequest) (*operations.V2GetLedgerInfoResponse, error) { return Client(srv).Ledger.V2.GetLedgerInfo(ctx, request) } -func CreateTransaction(ctx context.Context, srv *Server, request operations.V2CreateTransactionRequest) (*components.V2Transaction, error) { +func CreateTransaction(ctx context.Context, srv *testservice.Service, request operations.V2CreateTransactionRequest) (*components.V2Transaction, error) { response, err := Client(srv).Ledger.V2.CreateTransaction(ctx, request) if err != nil { @@ -44,7 +45,7 @@ func CreateTransaction(ctx context.Context, srv *Server, request operations.V2Cr return &response.V2CreateTransactionResponse.Data, nil } -func CreateBulk(ctx context.Context, srv *Server, request operations.V2CreateBulkRequest) ([]components.V2BulkElementResult, error) { +func CreateBulk(ctx context.Context, srv *testservice.Service, request operations.V2CreateBulkRequest) ([]components.V2BulkElementResult, error) { response, err := Client(srv).Ledger.V2.CreateBulk(ctx, request) if err != nil { return nil, mapSDKError(err) @@ -52,7 +53,7 @@ func CreateBulk(ctx context.Context, srv *Server, request operations.V2CreateBul return response.V2BulkResponse.Data, nil } -func GetBalancesAggregated(ctx context.Context, srv *Server, request operations.V2GetBalancesAggregatedRequest) (map[string]*big.Int, error) { +func GetBalancesAggregated(ctx context.Context, srv *testservice.Service, request operations.V2GetBalancesAggregatedRequest) (map[string]*big.Int, error) { response, err := Client(srv).Ledger.V2.GetBalancesAggregated(ctx, request) if err != nil { return nil, mapSDKError(err) @@ -60,7 +61,7 @@ func GetBalancesAggregated(ctx context.Context, srv *Server, request operations. return response.V2AggregateBalancesResponse.Data, nil } -func GetVolumesWithBalances(ctx context.Context, srv *Server, request operations.V2GetVolumesWithBalancesRequest) (*components.V2VolumesWithBalanceCursorResponseCursor, error) { +func GetVolumesWithBalances(ctx context.Context, srv *testservice.Service, request operations.V2GetVolumesWithBalancesRequest) (*components.V2VolumesWithBalanceCursorResponseCursor, error) { response, err := Client(srv).Ledger.V2.GetVolumesWithBalances(ctx, request) if err != nil { return nil, mapSDKError(err) @@ -68,37 +69,37 @@ func GetVolumesWithBalances(ctx context.Context, srv *Server, request operations return &response.V2VolumesWithBalanceCursorResponse.Cursor, nil } -func UpdateLedgerMetadata(ctx context.Context, srv *Server, request operations.V2UpdateLedgerMetadataRequest) error { +func UpdateLedgerMetadata(ctx context.Context, srv *testservice.Service, request operations.V2UpdateLedgerMetadataRequest) error { _, err := Client(srv).Ledger.V2.UpdateLedgerMetadata(ctx, request) return mapSDKError(err) } -func DeleteLedgerMetadata(ctx context.Context, srv *Server, request operations.V2DeleteLedgerMetadataRequest) error { +func DeleteLedgerMetadata(ctx context.Context, srv *testservice.Service, request operations.V2DeleteLedgerMetadataRequest) error { _, err := Client(srv).Ledger.V2.DeleteLedgerMetadata(ctx, request) return mapSDKError(err) } -func AddMetadataToAccount(ctx context.Context, srv *Server, request operations.V2AddMetadataToAccountRequest) error { +func AddMetadataToAccount(ctx context.Context, srv *testservice.Service, request operations.V2AddMetadataToAccountRequest) error { _, err := Client(srv).Ledger.V2.AddMetadataToAccount(ctx, request) return mapSDKError(err) } -func AddMetadataToTransaction(ctx context.Context, srv *Server, request operations.V2AddMetadataOnTransactionRequest) error { +func AddMetadataToTransaction(ctx context.Context, srv *testservice.Service, request operations.V2AddMetadataOnTransactionRequest) error { _, err := Client(srv).Ledger.V2.AddMetadataOnTransaction(ctx, request) return mapSDKError(err) } -func DeleteAccountMetadata(ctx context.Context, srv *Server, request operations.V2DeleteAccountMetadataRequest) error { +func DeleteAccountMetadata(ctx context.Context, srv *testservice.Service, request operations.V2DeleteAccountMetadataRequest) error { _, err := Client(srv).Ledger.V2.DeleteAccountMetadata(ctx, request) return mapSDKError(err) } -func DeleteTransactionMetadata(ctx context.Context, srv *Server, request operations.V2DeleteTransactionMetadataRequest) error { +func DeleteTransactionMetadata(ctx context.Context, srv *testservice.Service, request operations.V2DeleteTransactionMetadataRequest) error { _, err := Client(srv).Ledger.V2.DeleteTransactionMetadata(ctx, request) return mapSDKError(err) } -func RevertTransaction(ctx context.Context, srv *Server, request operations.V2RevertTransactionRequest) (*components.V2Transaction, error) { +func RevertTransaction(ctx context.Context, srv *testservice.Service, request operations.V2RevertTransactionRequest) (*components.V2Transaction, error) { response, err := Client(srv).Ledger.V2.RevertTransaction(ctx, request) if err != nil { @@ -108,7 +109,7 @@ func RevertTransaction(ctx context.Context, srv *Server, request operations.V2Re return &response.V2RevertTransactionResponse.Data, nil } -func GetTransaction(ctx context.Context, srv *Server, request operations.V2GetTransactionRequest) (*components.V2Transaction, error) { +func GetTransaction(ctx context.Context, srv *testservice.Service, request operations.V2GetTransactionRequest) (*components.V2Transaction, error) { response, err := Client(srv).Ledger.V2.GetTransaction(ctx, request) if err != nil { @@ -118,7 +119,7 @@ func GetTransaction(ctx context.Context, srv *Server, request operations.V2GetTr return &response.V2GetTransactionResponse.Data, nil } -func GetAccount(ctx context.Context, srv *Server, request operations.V2GetAccountRequest) (*components.V2Account, error) { +func GetAccount(ctx context.Context, srv *testservice.Service, request operations.V2GetAccountRequest) (*components.V2Account, error) { response, err := Client(srv).Ledger.V2.GetAccount(ctx, request) if err != nil { @@ -128,7 +129,7 @@ func GetAccount(ctx context.Context, srv *Server, request operations.V2GetAccoun return &response.V2AccountResponse.Data, nil } -func ListTransactions(ctx context.Context, srv *Server, request operations.V2ListTransactionsRequest) (*components.V2TransactionsCursorResponseCursor, error) { +func ListTransactions(ctx context.Context, srv *testservice.Service, request operations.V2ListTransactionsRequest) (*components.V2TransactionsCursorResponseCursor, error) { response, err := Client(srv).Ledger.V2.ListTransactions(ctx, request) if err != nil { @@ -138,7 +139,7 @@ func ListTransactions(ctx context.Context, srv *Server, request operations.V2Lis return &response.V2TransactionsCursorResponse.Cursor, nil } -func CountTransactions(ctx context.Context, srv *Server, request operations.V2CountTransactionsRequest) (int, error) { +func CountTransactions(ctx context.Context, srv *testservice.Service, request operations.V2CountTransactionsRequest) (int, error) { response, err := Client(srv).Ledger.V2.CountTransactions(ctx, request) if err != nil { @@ -153,7 +154,7 @@ func CountTransactions(ctx context.Context, srv *Server, request operations.V2Co return int(ret), nil } -func ListAccounts(ctx context.Context, srv *Server, request operations.V2ListAccountsRequest) (*components.V2AccountsCursorResponseCursor, error) { +func ListAccounts(ctx context.Context, srv *testservice.Service, request operations.V2ListAccountsRequest) (*components.V2AccountsCursorResponseCursor, error) { response, err := Client(srv).Ledger.V2.ListAccounts(ctx, request) if err != nil { @@ -163,7 +164,7 @@ func ListAccounts(ctx context.Context, srv *Server, request operations.V2ListAcc return &response.V2AccountsCursorResponse.Cursor, nil } -func ListLogs(ctx context.Context, srv *Server, request operations.V2ListLogsRequest) (*components.V2LogsCursorResponseCursor, error) { +func ListLogs(ctx context.Context, srv *testservice.Service, request operations.V2ListLogsRequest) (*components.V2LogsCursorResponseCursor, error) { response, err := Client(srv).Ledger.V2.ListLogs(ctx, request) if err != nil { @@ -173,7 +174,7 @@ func ListLogs(ctx context.Context, srv *Server, request operations.V2ListLogsReq return &response.V2LogsCursorResponse.Cursor, nil } -func CountAccounts(ctx context.Context, srv *Server, request operations.V2CountAccountsRequest) (int, error) { +func CountAccounts(ctx context.Context, srv *testservice.Service, request operations.V2CountAccountsRequest) (int, error) { response, err := Client(srv).Ledger.V2.CountAccounts(ctx, request) if err != nil { @@ -188,7 +189,7 @@ func CountAccounts(ctx context.Context, srv *Server, request operations.V2CountA return int(ret), nil } -func ListLedgers(ctx context.Context, srv *Server, request operations.V2ListLedgersRequest) (*components.V2LedgerListResponseCursor, error) { +func ListLedgers(ctx context.Context, srv *testservice.Service, request operations.V2ListLedgersRequest) (*components.V2LedgerListResponseCursor, error) { response, err := Client(srv).Ledger.V2.ListLedgers(ctx, request) if err != nil { @@ -198,7 +199,7 @@ func ListLedgers(ctx context.Context, srv *Server, request operations.V2ListLedg return &response.V2LedgerListResponse.Cursor, nil } -func GetAggregatedBalances(ctx context.Context, srv *Server, request operations.V2GetBalancesAggregatedRequest) (map[string]*big.Int, error) { +func GetAggregatedBalances(ctx context.Context, srv *testservice.Service, request operations.V2GetBalancesAggregatedRequest) (map[string]*big.Int, error) { response, err := Client(srv).Ledger.V2.GetBalancesAggregated(ctx, request) if err != nil { @@ -208,7 +209,7 @@ func GetAggregatedBalances(ctx context.Context, srv *Server, request operations. return response.GetV2AggregateBalancesResponse().Data, nil } -func Export(ctx context.Context, srv *Server, request operations.V2ExportLogsRequest) (io.Reader, error) { +func Export(ctx context.Context, srv *testservice.Service, request operations.V2ExportLogsRequest) (io.Reader, error) { response, err := Client(srv).Ledger.V2.ExportLogs(ctx, request) if err != nil { return nil, mapSDKError(err) @@ -222,7 +223,7 @@ func Export(ctx context.Context, srv *Server, request operations.V2ExportLogsReq return bytes.NewBuffer(data), nil } -func Import(ctx context.Context, srv *Server, request operations.V2ImportLogsRequest) error { +func Import(ctx context.Context, srv *testservice.Service, request operations.V2ImportLogsRequest) error { _, err := Client(srv).Ledger.V2.ImportLogs(ctx, request) return mapSDKError(err) } diff --git a/pkg/testserver/client.go b/pkg/testserver/client.go index e91d428859..40eefab61a 100644 --- a/pkg/testserver/client.go +++ b/pkg/testserver/client.go @@ -5,8 +5,8 @@ import ( ledgerclient "github.com/formancehq/ledger/pkg/client" ) -func Client(srv *testservice.Service[ServeConfiguration]) *ledgerclient.Formance { +func Client(srv *testservice.Service) *ledgerclient.Formance { return ledgerclient.New( - ledgerclient.WithServerURL(testservice.GetServerURL(srv)), + ledgerclient.WithServerURL(testservice.GetServerURL(srv).String()), ) } diff --git a/pkg/testserver/helpers.go b/pkg/testserver/helpers.go index 5eed64c761..0326125928 100644 --- a/pkg/testserver/helpers.go +++ b/pkg/testserver/helpers.go @@ -5,6 +5,8 @@ import ( "github.com/formancehq/go-libs/v2/bun/bunconnect" "github.com/formancehq/go-libs/v2/collectionutils" "github.com/formancehq/go-libs/v2/pointer" + "github.com/formancehq/go-libs/v2/testing/deferred" + "github.com/formancehq/go-libs/v2/testing/testservice" "github.com/formancehq/go-libs/v2/time" "github.com/formancehq/ledger/internal" "github.com/formancehq/ledger/pkg/client/models/components" @@ -59,11 +61,11 @@ func ConvertSDKPostingToCorePosting(p components.V2Posting) ledger.Posting { } } -func ConnectToDatabase(ctx context.Context, t interface{ +func ConnectToDatabase(ctx context.Context, t interface { require.TestingT Cleanup(func()) -}, testServer *Server) *bun.DB { - db, err := bunconnect.OpenSQLDB(ctx, bunconnect.ConnectionOptions(testServer.GetConfiguration().Configuration.PostgresConfiguration)) +}, dbOptions *deferred.Deferred[bunconnect.ConnectionOptions]) *bun.DB { + db, err := bunconnect.OpenSQLDB(ctx, dbOptions.GetValue()) require.NoError(t, err) t.Cleanup(func() { @@ -72,12 +74,12 @@ func ConnectToDatabase(ctx context.Context, t interface{ return db } -func Subscribe(t require.TestingT, server *Server) (*nats.Subscription, chan *nats.Msg) { +func Subscribe(t require.TestingT, srv *testservice.Service, natsURL *deferred.Deferred[string]) (*nats.Subscription, chan *nats.Msg) { ret := make(chan *nats.Msg) - conn, err := nats.Connect(server.GetConfiguration().Configuration.NatsURL) + conn, err := nats.Connect(natsURL.GetValue()) require.NoError(t, err) - subscription, err := conn.Subscribe(server.GetID(), func(msg *nats.Msg) { + subscription, err := conn.Subscribe(srv.GetID(), func(msg *nats.Msg) { ret <- msg }) require.NoError(t, err) diff --git a/pkg/testserver/matchers.go b/pkg/testserver/matchers.go index 63aa807edd..ff2dc9ebdf 100644 --- a/pkg/testserver/matchers.go +++ b/pkg/testserver/matchers.go @@ -7,6 +7,7 @@ import ( "fmt" "github.com/formancehq/go-libs/v2/pointer" "github.com/formancehq/go-libs/v2/publish" + "github.com/formancehq/go-libs/v2/testing/testservice" "github.com/formancehq/ledger/pkg/client/models/operations" "github.com/google/go-cmp/cmp" "github.com/invopop/jsonschema" @@ -21,9 +22,9 @@ import ( type HaveCoherentStateMatcher struct{} func (h HaveCoherentStateMatcher) Match(actual interface{}) (success bool, err error) { - srv, ok := actual.(*Server) + srv, ok := actual.(*testservice.Service) if !ok { - return false, fmt.Errorf("expect type %T", new(Server)) + return false, fmt.Errorf("expect type %T", new(testservice.Service)) } ctx := context.Background() diff --git a/pkg/testserver/server.go b/pkg/testserver/server.go index e9d9a38eda..1270cb1bf6 100644 --- a/pkg/testserver/server.go +++ b/pkg/testserver/server.go @@ -1,95 +1,36 @@ package testserver import ( + "context" "fmt" - "github.com/formancehq/go-libs/v2/bun/bunconnect" - "github.com/formancehq/go-libs/v2/publish" "github.com/formancehq/go-libs/v2/testing/testservice" "github.com/formancehq/ledger/cmd" ) -type PostgresConfiguration bunconnect.ConnectionOptions - -func (cfg PostgresConfiguration) GetArgs() []string { - args := make([]string, 0) - if cfg.DatabaseSourceName != "" { - args = append(args, "--"+bunconnect.PostgresURIFlag, cfg.DatabaseSourceName) - } - if cfg.MaxIdleConns != 0 { - args = append(args, "--"+bunconnect.PostgresMaxIdleConnsFlag, fmt.Sprint(cfg.MaxIdleConns)) - } - if cfg.MaxOpenConns != 0 { - args = append(args, "--"+bunconnect.PostgresMaxOpenConnsFlag, fmt.Sprint(cfg.MaxOpenConns)) - } - if cfg.ConnMaxIdleTime != 0 { - args = append(args, "--"+bunconnect.PostgresConnMaxIdleTimeFlag, fmt.Sprint(cfg.ConnMaxIdleTime)) +func ExperimentalFeaturesInstrumentation() testservice.InstrumentationFunc { + return func(ctx context.Context, runConfiguration *testservice.RunConfiguration) error { + runConfiguration.AppendArgs("--" + cmd.ExperimentalFeaturesFlag) + return nil } - return args } -type ServeConfiguration struct { - PostgresConfiguration PostgresConfiguration - NatsURL string - ExperimentalFeatures bool - DisableAutoUpgrade bool - BulkMaxSize int - ExperimentalNumscriptRewrite bool - MaxPageSize uint64 - DefaultPageSize uint64 - WorkerEnabled bool - WorkerConfiguration *WorkerConfiguration +func ExperimentalNumscriptRewriteInstrumentation() testservice.InstrumentationFunc { + return func(ctx context.Context, runConfiguration *testservice.RunConfiguration) error { + runConfiguration.AppendArgs("--" + cmd.NumscriptInterpreterFlag) + return nil + } } -func (cfg ServeConfiguration) GetArgs(serverID string) []string { - args := []string{ - "serve", - "--" + cmd.BindFlag, ":0", - } - args = append(args, cfg.PostgresConfiguration.GetArgs()...) - if !cfg.DisableAutoUpgrade { - args = append(args, "--"+cmd.AutoUpgradeFlag) - } - if cfg.WorkerEnabled { - args = append(args, "--"+cmd.WorkerEnabledFlag) - if cfg.WorkerConfiguration != nil { - args = append(args, cfg.WorkerConfiguration.GetArgs(serverID)...) - } - } - if cfg.ExperimentalFeatures { - args = append( - args, - "--"+cmd.ExperimentalFeaturesFlag, - ) +func MaxPageSizeInstrumentation(size uint64) testservice.InstrumentationFunc { + return func(ctx context.Context, runConfiguration *testservice.RunConfiguration) error { + runConfiguration.AppendArgs("--"+cmd.MaxPageSizeFlag, fmt.Sprint(size)) + return nil } - if cfg.BulkMaxSize != 0 { - args = append( - args, - "--"+cmd.BulkMaxSizeFlag, - fmt.Sprint(cfg.BulkMaxSize), - ) - } - if cfg.ExperimentalNumscriptRewrite { - args = append( - args, - "--"+cmd.NumscriptInterpreterFlag, - ) - } - if cfg.NatsURL != "" { - args = append( - args, - "--"+publish.PublisherNatsEnabledFlag, - "--"+publish.PublisherNatsURLFlag, cfg.NatsURL, - "--"+publish.PublisherTopicMappingFlag, fmt.Sprintf("*:%s", serverID), - ) - } - if cfg.MaxPageSize != 0 { - args = append(args, "--"+cmd.MaxPageSizeFlag, fmt.Sprint(cfg.MaxPageSize)) - } - if cfg.DefaultPageSize != 0 { - args = append(args, "--"+cmd.DefaultPageSizeFlag, fmt.Sprint(cfg.DefaultPageSize)) - } - - return args } -type Server = testservice.Service[ServeConfiguration] +func DefaultPageSizeInstrumentation(size uint64) testservice.InstrumentationFunc { + return func(ctx context.Context, runConfiguration *testservice.RunConfiguration) error { + runConfiguration.AppendArgs("--"+cmd.DefaultPageSizeFlag, fmt.Sprint(size)) + return nil + } +} diff --git a/pkg/testserver/utils.go b/pkg/testserver/utils.go index b754ae0774..455ecb85e5 100644 --- a/pkg/testserver/utils.go +++ b/pkg/testserver/utils.go @@ -1,46 +1,46 @@ package testserver import ( + "github.com/formancehq/go-libs/v2/bun/bunconnect" + "github.com/formancehq/go-libs/v2/testing/deferred" "github.com/formancehq/go-libs/v2/testing/testservice" - "github.com/formancehq/go-libs/v2/testing/utils" "github.com/formancehq/ledger/cmd" - "github.com/onsi/ginkgo/v2/dsl/core" - "io" ) -func DeferTestServer(debug bool, output io.Writer, configurationProvider func() ServeConfiguration) *utils.Deferred[*Server] { - return testservice.DeferNew[ServeConfiguration]( +func GetTestServerOptions(postgresConnectionOptions *deferred.Deferred[bunconnect.ConnectionOptions]) testservice.Option { + return testservice.WithInstruments( + testservice.AppendArgsInstrumentation("serve", "--"+cmd.BindFlag, ":0"), + testservice.PostgresInstrumentation(postgresConnectionOptions), + testservice.HTTPServerInstrumentation(), + ) +} + +func DeferTestServer(postgresConnectionOptions *deferred.Deferred[bunconnect.ConnectionOptions], options ...testservice.Option) *deferred.Deferred[*testservice.Service] { + return testservice.DeferNew( cmd.NewRootCommand, - func() testservice.Configuration[ServeConfiguration] { - return testservice.Configuration[ServeConfiguration]{ - CommonConfiguration: testservice.CommonConfiguration{ - Debug: debug, - Output: output, - }, - Configuration: configurationProvider(), - } - }, - testservice.WithLogger(core.GinkgoT()), - testservice.WithInstruments(testservice.HTTPServerInstrumentation()), + append([]testservice.Option{ + GetTestServerOptions(postgresConnectionOptions), + }, options...)..., ) } -func NewTestServer(configuration testservice.Configuration[ServeConfiguration], options ...testservice.Option) *testservice.Service[ServeConfiguration] { - return testservice.New[ServeConfiguration]( +func NewTestServer(postgresConnectionOptions *deferred.Deferred[bunconnect.ConnectionOptions], options ...testservice.Option) *testservice.Service { + return testservice.New( cmd.NewRootCommand, - configuration, - append(options, testservice.WithInstruments(testservice.HTTPServerInstrumentation()))..., + append([]testservice.Option{ + GetTestServerOptions(postgresConnectionOptions), + }, options...)..., ) } -func DeferTestWorker(debug bool, output io.Writer, configurationProvider func() WorkerConfiguration) *utils.Deferred[*Worker] { - return testservice.DeferNew[WorkerConfiguration](cmd.NewRootCommand, func() testservice.Configuration[WorkerConfiguration] { - return testservice.Configuration[WorkerConfiguration]{ - CommonConfiguration: testservice.CommonConfiguration{ - Debug: debug, - Output: output, - }, - Configuration: configurationProvider(), - } - }) +func DeferTestWorker(postgresConnectionOptions *deferred.Deferred[bunconnect.ConnectionOptions], options ...testservice.Option) *deferred.Deferred[*testservice.Service] { + return testservice.DeferNew( + cmd.NewRootCommand, + append([]testservice.Option{ + testservice.WithInstruments( + testservice.AppendArgsInstrumentation("worker"), + testservice.PostgresInstrumentation(postgresConnectionOptions), + ), + }, options...)..., + ) } diff --git a/pkg/testserver/worker.go b/pkg/testserver/worker.go index a1e6b32f92..670118c2a3 100644 --- a/pkg/testserver/worker.go +++ b/pkg/testserver/worker.go @@ -1,28 +1,22 @@ package testserver import ( + "context" "github.com/formancehq/go-libs/v2/testing/testservice" "github.com/formancehq/ledger/cmd" "strconv" ) -type WorkerConfiguration struct { - PostgresConfiguration PostgresConfiguration - LogsHashBlockMaxSize int - LogsHashBlockCRONSpec string +func LogsHashBlockMaxSizeInstrumentation(size int) testservice.InstrumentationFunc { + return func(ctx context.Context, runConfiguration *testservice.RunConfiguration) error { + runConfiguration.AppendArgs("--"+cmd.WorkerAsyncBlockHasherMaxBlockSizeFlag, strconv.Itoa(size)) + return nil + } } -func (cfg WorkerConfiguration) GetArgs(_ string) []string { - args := []string{"worker"} - args = append(args, cfg.PostgresConfiguration.GetArgs()...) - if cfg.LogsHashBlockMaxSize > 0 { - args = append(args, "--"+cmd.WorkerAsyncBlockHasherMaxBlockSizeFlag, strconv.Itoa(cfg.LogsHashBlockMaxSize)) - } - if cfg.LogsHashBlockCRONSpec != "" { - args = append(args, "--"+cmd.WorkerAsyncBlockHasherScheduleFlag, cfg.LogsHashBlockCRONSpec) +func LogsHashBlockCRONSpecInstrumentation(spec string) testservice.InstrumentationFunc { + return func(ctx context.Context, runConfiguration *testservice.RunConfiguration) error { + runConfiguration.AppendArgs("--"+cmd.WorkerAsyncBlockHasherScheduleFlag, spec) + return nil } - - return args } - -type Worker = testservice.Service[WorkerConfiguration] diff --git a/test/e2e/api_accounts_list_test.go b/test/e2e/api_accounts_list_test.go index ca444f7118..fee662fb3c 100644 --- a/test/e2e/api_accounts_list_test.go +++ b/test/e2e/api_accounts_list_test.go @@ -6,6 +6,10 @@ import ( "fmt" "github.com/formancehq/go-libs/v2/logging" . "github.com/formancehq/go-libs/v2/testing/api" + "github.com/formancehq/go-libs/v2/testing/deferred" + "github.com/formancehq/go-libs/v2/testing/platform/natstesting" + "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" + "github.com/formancehq/go-libs/v2/testing/testservice" "github.com/formancehq/ledger/pkg/client/models/components" "github.com/formancehq/ledger/pkg/client/models/operations" . "github.com/formancehq/ledger/pkg/testserver" @@ -26,12 +30,16 @@ var _ = Context("Ledger accounts list API tests", func() { ctx = logging.TestingContext() ) - testServer := DeferTestServer(debug, GinkgoWriter, func() ServeConfiguration { - return ServeConfiguration{ - PostgresConfiguration: PostgresConfiguration(db.GetValue().ConnectionOptions()), - NatsURL: natsServer.GetValue().ClientURL(), - } - }) + testServer := DeferTestServer( + deferred.DeferMap(db, (*pgtesting.Database).ConnectionOptions), + testservice.WithInstruments( + testservice.NatsInstrumentation(deferred.DeferMap(natsServer, (*natstesting.NatsServer).ClientURL)), + testservice.DebugInstrumentation(debug), + testservice.OutputInstrumentation(GinkgoWriter), + ), + testservice.WithLogger(GinkgoT()), + ) + BeforeEach(func() { err := CreateLedger(ctx, testServer.GetValue(), operations.V2CreateLedgerRequest{ Ledger: "default", diff --git a/test/e2e/api_accounts_metadata_test.go b/test/e2e/api_accounts_metadata_test.go index 73e3b067f8..49afcab471 100644 --- a/test/e2e/api_accounts_metadata_test.go +++ b/test/e2e/api_accounts_metadata_test.go @@ -4,6 +4,10 @@ package test_suite import ( "github.com/formancehq/go-libs/v2/logging" + "github.com/formancehq/go-libs/v2/testing/deferred" + "github.com/formancehq/go-libs/v2/testing/platform/natstesting" + "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" + "github.com/formancehq/go-libs/v2/testing/testservice" "github.com/formancehq/ledger/pkg/client/models/components" "github.com/formancehq/ledger/pkg/client/models/operations" ledgerevents "github.com/formancehq/ledger/pkg/events" @@ -17,17 +21,21 @@ var _ = Context("Ledger accounts metadata API tests", func() { var ( db = UseTemplatedDatabase() ctx = logging.TestingContext() + natsURL = deferred.DeferMap(natsServer, (*natstesting.NatsServer).ClientURL) ) - testServer := DeferTestServer(debug, GinkgoWriter, func() ServeConfiguration { - return ServeConfiguration{ - PostgresConfiguration: PostgresConfiguration(db.GetValue().ConnectionOptions()), - NatsURL: natsServer.GetValue().ClientURL(), - } - }) + testServer := DeferTestServer( + deferred.DeferMap(db, (*pgtesting.Database).ConnectionOptions), + testservice.WithInstruments( + testservice.NatsInstrumentation(natsURL), + testservice.DebugInstrumentation(debug), + testservice.OutputInstrumentation(GinkgoWriter), + ), + testservice.WithLogger(GinkgoT()), + ) var events chan *nats.Msg BeforeEach(func() { - _, events = Subscribe(GinkgoT(), testServer.GetValue()) + _, events = Subscribe(GinkgoT(), testServer.GetValue(), natsURL) }) BeforeEach(func() { diff --git a/test/e2e/api_balances_aggregated_test.go b/test/e2e/api_balances_aggregated_test.go index 492e979743..3099e69cbb 100644 --- a/test/e2e/api_balances_aggregated_test.go +++ b/test/e2e/api_balances_aggregated_test.go @@ -5,6 +5,9 @@ package test_suite import ( "github.com/formancehq/go-libs/v2/logging" "github.com/formancehq/go-libs/v2/pointer" + "github.com/formancehq/go-libs/v2/testing/deferred" + "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" + "github.com/formancehq/go-libs/v2/testing/testservice" "github.com/formancehq/ledger/pkg/client/models/components" "github.com/formancehq/ledger/pkg/client/models/operations" . "github.com/formancehq/ledger/pkg/testserver" @@ -21,12 +24,14 @@ var _ = Context("Ledger engine tests", func() { ctx = logging.TestingContext() ) - testServer := DeferTestServer(debug, GinkgoWriter, func() ServeConfiguration { - return ServeConfiguration{ - PostgresConfiguration: PostgresConfiguration(db.GetValue().ConnectionOptions()), - NatsURL: natsServer.GetValue().ClientURL(), - } - }) + testServer := DeferTestServer( + deferred.DeferMap(db, (*pgtesting.Database).ConnectionOptions), + testservice.WithInstruments( + testservice.DebugInstrumentation(debug), + testservice.OutputInstrumentation(GinkgoWriter), + ), + testservice.WithLogger(GinkgoT()), + ) now := time.Now().UTC().Round(time.Second) When("creating two transactions on a ledger with custom metadata", func() { var firstTransactionsInsertedAt time.Time diff --git a/test/e2e/api_bulk_test.go b/test/e2e/api_bulk_test.go index bbf5318667..15068cc6be 100644 --- a/test/e2e/api_bulk_test.go +++ b/test/e2e/api_bulk_test.go @@ -6,6 +6,9 @@ import ( "bytes" "encoding/json" "github.com/formancehq/go-libs/v2/pointer" + "github.com/formancehq/go-libs/v2/testing/deferred" + "github.com/formancehq/go-libs/v2/testing/platform/natstesting" + "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" "github.com/formancehq/go-libs/v2/testing/testservice" ledger "github.com/formancehq/ledger/internal" "github.com/formancehq/ledger/internal/bus" @@ -34,21 +37,25 @@ var _ = Context("Ledger engine tests", func() { events chan *nats.Msg bulkResponse []components.V2BulkElementResult bulkMaxSize = 100 + natsURL = deferred.DeferMap(natsServer, (*natstesting.NatsServer).ClientURL) + ) + + testServer := DeferTestServer( + deferred.DeferMap(db, (*pgtesting.Database).ConnectionOptions), + testservice.WithInstruments( + testservice.NatsInstrumentation(natsURL), + testservice.DebugInstrumentation(debug), + testservice.OutputInstrumentation(GinkgoWriter), + ), + testservice.WithLogger(GinkgoT()), ) - testServer := DeferTestServer(debug, GinkgoWriter, func() ServeConfiguration { - return ServeConfiguration{ - PostgresConfiguration: PostgresConfiguration(db.GetValue().ConnectionOptions()), - NatsURL: natsServer.GetValue().ClientURL(), - BulkMaxSize: bulkMaxSize, - } - }) BeforeEach(func() { err := CreateLedger(ctx, testServer.GetValue(), operations.V2CreateLedgerRequest{ Ledger: "default", }) Expect(err).To(BeNil()) - _, events = Subscribe(GinkgoT(), testServer.GetValue()) + _, events = Subscribe(GinkgoT(), testServer.GetValue(), natsURL) }) When("creating a bulk on a ledger", func() { var ( @@ -238,7 +245,7 @@ var _ = Context("Ledger engine tests", func() { } stream.Write([]byte("\n")) - req, err := http.NewRequest(http.MethodPost, testservice.GetServerURL(testServer.GetValue())+"/v2/default/_bulk", stream) + req, err := http.NewRequest(http.MethodPost, testservice.GetServerURL(testServer.GetValue()).String()+"/v2/default/_bulk", stream) req.Header.Set("Content-Type", "application/vnd.formance.ledger.api.v2.bulk+json-stream") Expect(err).To(Succeed()) diff --git a/test/e2e/api_ledgers_create_test.go b/test/e2e/api_ledgers_create_test.go index eb05f09d94..3282465d60 100644 --- a/test/e2e/api_ledgers_create_test.go +++ b/test/e2e/api_ledgers_create_test.go @@ -6,6 +6,10 @@ import ( "github.com/formancehq/go-libs/v2/logging" "github.com/formancehq/go-libs/v2/pointer" . "github.com/formancehq/go-libs/v2/testing/api" + "github.com/formancehq/go-libs/v2/testing/deferred" + "github.com/formancehq/go-libs/v2/testing/platform/natstesting" + "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" + "github.com/formancehq/go-libs/v2/testing/testservice" "github.com/formancehq/ledger/pkg/client/models/components" "github.com/formancehq/ledger/pkg/client/models/operations" "github.com/formancehq/ledger/pkg/features" @@ -17,17 +21,22 @@ import ( var _ = Context("Ledger engine tests", func() { var ( - db = UseTemplatedDatabase() - ctx = logging.TestingContext() + db = UseTemplatedDatabase() + ctx = logging.TestingContext() + natsURL = deferred.DeferMap(natsServer, (*natstesting.NatsServer).ClientURL) + ) + + testServer := DeferTestServer( + deferred.DeferMap(db, (*pgtesting.Database).ConnectionOptions), + testservice.WithInstruments( + testservice.NatsInstrumentation(natsURL), + testservice.DebugInstrumentation(debug), + testservice.OutputInstrumentation(GinkgoWriter), + ExperimentalFeaturesInstrumentation(), + ), + testservice.WithLogger(GinkgoT()), ) - testServer := DeferTestServer(debug, GinkgoWriter, func() ServeConfiguration { - return ServeConfiguration{ - PostgresConfiguration: PostgresConfiguration(db.GetValue().ConnectionOptions()), - NatsURL: natsServer.GetValue().ClientURL(), - ExperimentalFeatures: true, - } - }) When("creating a new ledger", func() { var ( createLedgerRequest operations.V2CreateLedgerRequest diff --git a/test/e2e/api_ledgers_import_test.go b/test/e2e/api_ledgers_import_test.go index 7cd321080d..133fca1278 100644 --- a/test/e2e/api_ledgers_import_test.go +++ b/test/e2e/api_ledgers_import_test.go @@ -7,6 +7,9 @@ import ( "github.com/formancehq/go-libs/v2/logging" "github.com/formancehq/go-libs/v2/pointer" . "github.com/formancehq/go-libs/v2/testing/api" + "github.com/formancehq/go-libs/v2/testing/deferred" + "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" + "github.com/formancehq/go-libs/v2/testing/testservice" "github.com/formancehq/ledger/pkg/client/models/components" "github.com/formancehq/ledger/pkg/client/models/operations" "github.com/formancehq/ledger/pkg/features" @@ -20,17 +23,21 @@ import ( var _ = Context("Ledger engine tests", func() { var ( - db = UseTemplatedDatabase() - ctx = logging.TestingContext() + db = UseTemplatedDatabase() + ctx = logging.TestingContext() + connectionOptions = deferred.DeferMap(db, (*pgtesting.Database).ConnectionOptions) + ) + + testServer := DeferTestServer( + connectionOptions, + testservice.WithInstruments( + testservice.DebugInstrumentation(debug), + testservice.OutputInstrumentation(GinkgoWriter), + ExperimentalFeaturesInstrumentation(), + ), + testservice.WithLogger(GinkgoT()), ) - testServer := DeferTestServer(debug, GinkgoWriter, func() ServeConfiguration { - return ServeConfiguration{ - PostgresConfiguration: PostgresConfiguration(db.GetValue().ConnectionOptions()), - NatsURL: natsServer.GetValue().ClientURL(), - ExperimentalFeatures: true, - } - }) When("creating a new ledger", func() { var ( createLedgerRequest operations.V2CreateLedgerRequest @@ -331,7 +338,7 @@ var _ = Context("Ledger engine tests", func() { // we take a lock on the ledgers table to force the process to wait // while we will make a concurrent request JustBeforeEach(func() { - db = ConnectToDatabase(ctx, GinkgoT(), testServer.GetValue()) + db = ConnectToDatabase(ctx, GinkgoT(), connectionOptions) sqlTx, err = db.BeginTx(ctx, &sql.TxOptions{}) Expect(err).To(BeNil()) diff --git a/test/e2e/api_ledgers_list_test.go b/test/e2e/api_ledgers_list_test.go index ba7c06da37..560c5274f0 100644 --- a/test/e2e/api_ledgers_list_test.go +++ b/test/e2e/api_ledgers_list_test.go @@ -6,6 +6,9 @@ import ( "fmt" "github.com/formancehq/go-libs/v2/logging" "github.com/formancehq/go-libs/v2/pointer" + "github.com/formancehq/go-libs/v2/testing/deferred" + "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" + "github.com/formancehq/go-libs/v2/testing/testservice" "github.com/formancehq/ledger/pkg/client/models/components" "github.com/formancehq/ledger/pkg/client/models/operations" . "github.com/formancehq/ledger/pkg/testserver" @@ -19,16 +22,18 @@ var _ = Context("Ledger engine tests", func() { ctx = logging.TestingContext() ) - testServer := DeferTestServer(debug, GinkgoWriter, func() ServeConfiguration { - return ServeConfiguration{ - PostgresConfiguration: PostgresConfiguration(db.GetValue().ConnectionOptions()), - NatsURL: natsServer.GetValue().ClientURL(), - MaxPageSize: 15, - DefaultPageSize: 15, - } - }) + testServer := DeferTestServer( + deferred.DeferMap(db, (*pgtesting.Database).ConnectionOptions), + testservice.WithInstruments( + testservice.DebugInstrumentation(debug), + testservice.OutputInstrumentation(GinkgoWriter), + MaxPageSizeInstrumentation(15), + DefaultPageSizeInstrumentation(15), + ), + testservice.WithLogger(GinkgoT()), + ) - When("creating 10 ledger", func() { + When("creating 20 ledger", func() { BeforeEach(func() { for i := range 20 { err := CreateLedger(ctx, testServer.GetValue(), operations.V2CreateLedgerRequest{ diff --git a/test/e2e/api_ledgers_metadata_test.go b/test/e2e/api_ledgers_metadata_test.go index abd52ffa0e..82d7210658 100644 --- a/test/e2e/api_ledgers_metadata_test.go +++ b/test/e2e/api_ledgers_metadata_test.go @@ -4,6 +4,9 @@ package test_suite import ( "github.com/formancehq/go-libs/v2/logging" + "github.com/formancehq/go-libs/v2/testing/deferred" + "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" + "github.com/formancehq/go-libs/v2/testing/testservice" "github.com/formancehq/ledger/pkg/client/models/operations" . "github.com/formancehq/ledger/pkg/testserver" . "github.com/onsi/ginkgo/v2" @@ -16,12 +19,15 @@ var _ = Context("Ledger engine tests", func() { ctx = logging.TestingContext() ) - testServer := DeferTestServer(debug, GinkgoWriter, func() ServeConfiguration { - return ServeConfiguration{ - PostgresConfiguration: PostgresConfiguration(db.GetValue().ConnectionOptions()), - NatsURL: natsServer.GetValue().ClientURL(), - } - }) + testServer := DeferTestServer( + deferred.DeferMap(db, (*pgtesting.Database).ConnectionOptions), + testservice.WithInstruments( + testservice.DebugInstrumentation(debug), + testservice.OutputInstrumentation(GinkgoWriter), + ), + testservice.WithLogger(GinkgoT()), + ) + When("creating a ledger", func() { BeforeEach(func() { err := CreateLedger(ctx, testServer.GetValue(), operations.V2CreateLedgerRequest{ diff --git a/test/e2e/api_logs_list_test.go b/test/e2e/api_logs_list_test.go index 11bea154c6..d06f44b158 100644 --- a/test/e2e/api_logs_list_test.go +++ b/test/e2e/api_logs_list_test.go @@ -6,6 +6,9 @@ import ( "fmt" "github.com/formancehq/go-libs/v2/logging" "github.com/formancehq/go-libs/v2/pointer" + "github.com/formancehq/go-libs/v2/testing/deferred" + "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" + "github.com/formancehq/go-libs/v2/testing/testservice" "github.com/formancehq/ledger/pkg/client/models/components" "github.com/formancehq/ledger/pkg/client/models/operations" . "github.com/formancehq/ledger/pkg/testserver" @@ -22,12 +25,15 @@ var _ = Context("Ledger logs list API tests", func() { ctx = logging.TestingContext() ) - testServer := DeferTestServer(debug, GinkgoWriter, func() ServeConfiguration { - return ServeConfiguration{ - PostgresConfiguration: PostgresConfiguration(db.GetValue().ConnectionOptions()), - NatsURL: natsServer.GetValue().ClientURL(), - } - }) + testServer := DeferTestServer( + deferred.DeferMap(db, (*pgtesting.Database).ConnectionOptions), + testservice.WithInstruments( + testservice.DebugInstrumentation(debug), + testservice.OutputInstrumentation(GinkgoWriter), + ), + testservice.WithLogger(GinkgoT()), + ) + BeforeEach(func() { err := CreateLedger(ctx, testServer.GetValue(), operations.V2CreateLedgerRequest{ Ledger: "default", diff --git a/test/e2e/api_transactions_create_test.go b/test/e2e/api_transactions_create_test.go index 1cecc4b3c1..bf3dd5a2e3 100644 --- a/test/e2e/api_transactions_create_test.go +++ b/test/e2e/api_transactions_create_test.go @@ -3,6 +3,10 @@ package test_suite import ( + "github.com/formancehq/go-libs/v2/testing/deferred" + "github.com/formancehq/go-libs/v2/testing/platform/natstesting" + "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" + "github.com/formancehq/go-libs/v2/testing/testservice" "math/big" "time" @@ -32,16 +36,23 @@ var _ = Context("Ledger transactions create API tests", func() { } { Context(data.description, func() { var ( - db = UseTemplatedDatabase() - ctx = logging.TestingContext() + db = UseTemplatedDatabase() + ctx = logging.TestingContext() + natsURL = deferred.DeferMap(natsServer, (*natstesting.NatsServer).ClientURL) + ) + instruments := []testservice.Instrumentation{ + testservice.NatsInstrumentation(natsURL), + testservice.DebugInstrumentation(debug), + testservice.OutputInstrumentation(GinkgoWriter), + } + if data.numscriptRewrite { + instruments = append(instruments, ExperimentalNumscriptRewriteInstrumentation()) + } + testServer := DeferTestServer( + deferred.DeferMap(db, (*pgtesting.Database).ConnectionOptions), + testservice.WithInstruments(instruments...), + testservice.WithLogger(GinkgoT()), ) - testServer := DeferTestServer(debug, GinkgoWriter, func() ServeConfiguration { - return ServeConfiguration{ - PostgresConfiguration: PostgresConfiguration(db.GetValue().ConnectionOptions()), - NatsURL: natsServer.GetValue().ClientURL(), - ExperimentalNumscriptRewrite: data.numscriptRewrite, - } - }) BeforeEach(func() { err := CreateLedger(ctx, testServer.GetValue(), operations.V2CreateLedgerRequest{ @@ -64,7 +75,7 @@ var _ = Context("Ledger transactions create API tests", func() { err error ) BeforeEach(func() { - _, events = Subscribe(GinkgoT(), testServer.GetValue()) + _, events = Subscribe(GinkgoT(), testServer.GetValue(), natsURL) req = operations.V2CreateTransactionRequest{ V2PostTransaction: components.V2PostTransaction{ Timestamp: ×tamp, diff --git a/test/e2e/api_transactions_list_test.go b/test/e2e/api_transactions_list_test.go index 38606df999..25f381a68f 100644 --- a/test/e2e/api_transactions_list_test.go +++ b/test/e2e/api_transactions_list_test.go @@ -8,6 +8,9 @@ import ( "github.com/formancehq/go-libs/v2/logging" "github.com/formancehq/go-libs/v2/query" . "github.com/formancehq/go-libs/v2/testing/api" + "github.com/formancehq/go-libs/v2/testing/deferred" + "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" + "github.com/formancehq/go-libs/v2/testing/testservice" libtime "github.com/formancehq/go-libs/v2/time" "github.com/formancehq/ledger/internal/storage/common" "github.com/formancehq/ledger/pkg/client/models/components" @@ -29,12 +32,15 @@ var _ = Context("Ledger transactions list API tests", func() { ctx = logging.TestingContext() ) - testServer := DeferTestServer(debug, GinkgoWriter, func() ServeConfiguration { - return ServeConfiguration{ - PostgresConfiguration: PostgresConfiguration(db.GetValue().ConnectionOptions()), - NatsURL: natsServer.GetValue().ClientURL(), - } - }) + testServer := DeferTestServer( + deferred.DeferMap(db, (*pgtesting.Database).ConnectionOptions), + testservice.WithInstruments( + testservice.DebugInstrumentation(debug), + testservice.OutputInstrumentation(GinkgoWriter), + ), + testservice.WithLogger(GinkgoT()), + ) + JustBeforeEach(func() { err := CreateLedger(ctx, testServer.GetValue(), operations.V2CreateLedgerRequest{ Ledger: "default", diff --git a/test/e2e/api_transactions_metadata_test.go b/test/e2e/api_transactions_metadata_test.go index 586a68b5c7..ca90aa677f 100644 --- a/test/e2e/api_transactions_metadata_test.go +++ b/test/e2e/api_transactions_metadata_test.go @@ -5,6 +5,9 @@ package test_suite import ( "github.com/formancehq/go-libs/v2/logging" . "github.com/formancehq/go-libs/v2/testing/api" + "github.com/formancehq/go-libs/v2/testing/deferred" + "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" + "github.com/formancehq/go-libs/v2/testing/testservice" "github.com/formancehq/ledger/pkg/client/models/components" "github.com/formancehq/ledger/pkg/client/models/operations" . "github.com/formancehq/ledger/pkg/testserver" @@ -21,12 +24,15 @@ var _ = Context("Ledger accounts list API tests", func() { ctx = logging.TestingContext() ) - testServer := DeferTestServer(debug, GinkgoWriter, func() ServeConfiguration { - return ServeConfiguration{ - PostgresConfiguration: PostgresConfiguration(db.GetValue().ConnectionOptions()), - NatsURL: natsServer.GetValue().ClientURL(), - } - }) + testServer := DeferTestServer( + deferred.DeferMap(db, (*pgtesting.Database).ConnectionOptions), + testservice.WithInstruments( + testservice.DebugInstrumentation(debug), + testservice.OutputInstrumentation(GinkgoWriter), + ), + testservice.WithLogger(GinkgoT()), + ) + BeforeEach(func() { err := CreateLedger(ctx, testServer.GetValue(), operations.V2CreateLedgerRequest{ Ledger: "default", diff --git a/test/e2e/api_transactions_revert_test.go b/test/e2e/api_transactions_revert_test.go index 8a153d4bab..f616be4ffb 100644 --- a/test/e2e/api_transactions_revert_test.go +++ b/test/e2e/api_transactions_revert_test.go @@ -3,6 +3,10 @@ package test_suite import ( + "github.com/formancehq/go-libs/v2/testing/deferred" + "github.com/formancehq/go-libs/v2/testing/platform/natstesting" + "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" + "github.com/formancehq/go-libs/v2/testing/testservice" "math/big" "time" @@ -24,14 +28,19 @@ var _ = Context("Ledger revert transactions API tests", func() { var ( db = UseTemplatedDatabase() ctx = logging.TestingContext() + natsURL = deferred.DeferMap(natsServer, (*natstesting.NatsServer).ClientURL) + ) + + testServer := DeferTestServer( + deferred.DeferMap(db, (*pgtesting.Database).ConnectionOptions), + testservice.WithInstruments( + testservice.NatsInstrumentation(natsURL), + testservice.DebugInstrumentation(debug), + testservice.OutputInstrumentation(GinkgoWriter), + ), + testservice.WithLogger(GinkgoT()), ) - testServer := DeferTestServer(debug, GinkgoWriter, func() ServeConfiguration { - return ServeConfiguration{ - PostgresConfiguration: PostgresConfiguration(db.GetValue().ConnectionOptions()), - NatsURL: natsServer.GetValue().ClientURL(), - } - }) BeforeEach(func() { err := CreateLedger(ctx, testServer.GetValue(), operations.V2CreateLedgerRequest{ Ledger: "default", @@ -46,7 +55,7 @@ var _ = Context("Ledger revert transactions API tests", func() { err error ) BeforeEach(func() { - _, events = Subscribe(GinkgoT(), testServer.GetValue()) + _, events = Subscribe(GinkgoT(), testServer.GetValue(), natsURL) tx, err = CreateTransaction( ctx, testServer.GetValue(), diff --git a/test/e2e/api_volumes_test.go b/test/e2e/api_volumes_test.go index 2a5bcfd951..e6638376ff 100644 --- a/test/e2e/api_volumes_test.go +++ b/test/e2e/api_volumes_test.go @@ -5,6 +5,9 @@ package test_suite import ( "github.com/formancehq/go-libs/v2/logging" "github.com/formancehq/go-libs/v2/pointer" + "github.com/formancehq/go-libs/v2/testing/deferred" + "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" + "github.com/formancehq/go-libs/v2/testing/testservice" "github.com/formancehq/ledger/pkg/client/models/components" "github.com/formancehq/ledger/pkg/client/models/operations" . "github.com/formancehq/ledger/pkg/testserver" @@ -31,12 +34,14 @@ var _ = Context("Ledger accounts list API tests", func() { ctx = logging.TestingContext() ) - testServer := DeferTestServer(debug, GinkgoWriter, func() ServeConfiguration { - return ServeConfiguration{ - PostgresConfiguration: PostgresConfiguration(db.GetValue().ConnectionOptions()), - NatsURL: natsServer.GetValue().ClientURL(), - } - }) + testServer := DeferTestServer( + deferred.DeferMap(db, (*pgtesting.Database).ConnectionOptions), + testservice.WithInstruments( + testservice.DebugInstrumentation(debug), + testservice.OutputInstrumentation(GinkgoWriter), + ), + testservice.WithLogger(GinkgoT()), + ) transactions := []Transaction{ {Amount: 100, Asset: "USD", Source: "world", Destination: "account:user1", EffectiveDate: now.Add(-4 * time.Hour)}, //user1:100, world:-100 diff --git a/test/e2e/app_lifecycle_test.go b/test/e2e/app_lifecycle_test.go index deadd80aa2..287316a962 100644 --- a/test/e2e/app_lifecycle_test.go +++ b/test/e2e/app_lifecycle_test.go @@ -9,6 +9,8 @@ import ( "github.com/formancehq/go-libs/v2/bun/bunconnect" "github.com/formancehq/go-libs/v2/logging" "github.com/formancehq/go-libs/v2/pointer" + "github.com/formancehq/go-libs/v2/testing/deferred" + "github.com/formancehq/go-libs/v2/testing/platform/natstesting" "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" "github.com/formancehq/go-libs/v2/testing/testservice" "github.com/formancehq/go-libs/v2/time" @@ -36,18 +38,26 @@ var _ = Context("Ledger application lifecycle tests", func() { Context("Pending transaction should be fully processed before stopping or restarting the server", func() { db := UseTemplatedDatabase() - testServer := DeferTestServer(debug, GinkgoWriter, func() ServeConfiguration { - return ServeConfiguration{ - PostgresConfiguration: PostgresConfiguration(bunconnect.ConnectionOptions{ - DatabaseSourceName: db.GetValue().ConnectionOptions().DatabaseSourceName, - MaxOpenConns: 100, - }), - NatsURL: natsServer.GetValue().ClientURL(), + connectionOptions := deferred.DeferMap(db, func(from *pgtesting.Database) bunconnect.ConnectionOptions { + return bunconnect.ConnectionOptions{ + DatabaseSourceName: from.ConnectionOptions().DatabaseSourceName, + MaxOpenConns: 100, } }) + natsURL := deferred.DeferMap(natsServer, (*natstesting.NatsServer).ClientURL) + testServer := DeferTestServer( + connectionOptions, + testservice.WithInstruments( + testservice.NatsInstrumentation(natsURL), + testservice.DebugInstrumentation(debug), + testservice.OutputInstrumentation(GinkgoWriter), + ), + testservice.WithLogger(GinkgoT()), + ) + var events chan *nats.Msg BeforeEach(func() { - _, events = Subscribe(GinkgoT(), testServer.GetValue()) + _, events = Subscribe(GinkgoT(), testServer.GetValue(), natsURL) }) When("starting the service", func() { @@ -78,7 +88,7 @@ var _ = Context("Ledger application lifecycle tests", func() { // lock logs table to block transactions creation requests // the first tx will block on the log insertion // the next transaction will block earlier on advisory lock acquirement for accounts - db := ConnectToDatabase(ctx, GinkgoT(), testServer.GetValue()) + db := ConnectToDatabase(ctx, GinkgoT(), connectionOptions) sqlTx, err = db.BeginTx(ctx, &sql.TxOptions{}) Expect(err).To(BeNil()) DeferCleanup(func() { @@ -197,13 +207,15 @@ var _ = Context("Ledger application lifecycle tests", func() { Expect(migrator.UpByOne(ctx)).To(BeNil()) } }) - testServer := DeferTestServer(debug, GinkgoWriter, func() ServeConfiguration { - return ServeConfiguration{ - PostgresConfiguration: PostgresConfiguration(db.GetValue().ConnectionOptions()), - NatsURL: natsServer.GetValue().ClientURL(), - DisableAutoUpgrade: true, - } - }) + testServer := DeferTestServer( + deferred.DeferMap(db, (*pgtesting.Database).ConnectionOptions), + testservice.WithInstruments( + testservice.NatsInstrumentation(deferred.DeferMap(natsServer, (*natstesting.NatsServer).ClientURL)), + testservice.DebugInstrumentation(debug), + testservice.OutputInstrumentation(GinkgoWriter), + ), + ) + It("should be ok", func() { By("we should be able to create a new transaction", func() { _, err := CreateTransaction(ctx, testServer.GetValue(), operations.V2CreateTransactionRequest{ @@ -235,16 +247,19 @@ var _ = Context("Ledger application lifecycle tests", func() { var _ = Context("Ledger downgrade tests", func() { var ( - db = UseTemplatedDatabase() - ctx = logging.TestingContext() + db = UseTemplatedDatabase() + connectionOptions = deferred.DeferMap(db, (*pgtesting.Database).ConnectionOptions) + ctx = logging.TestingContext() ) - testServer := DeferTestServer(debug, GinkgoWriter, func() ServeConfiguration { - return ServeConfiguration{ - PostgresConfiguration: PostgresConfiguration(db.GetValue().ConnectionOptions()), - NatsURL: natsServer.GetValue().ClientURL(), - } - }) + testServer := DeferTestServer( + connectionOptions, + testservice.WithInstruments( + testservice.DebugInstrumentation(debug), + testservice.OutputInstrumentation(GinkgoWriter), + ), + testservice.WithLogger(GinkgoT()), + ) When("inserting new migrations into the database", func() { BeforeEach(func() { @@ -261,7 +276,7 @@ var _ = Context("Ledger downgrade tests", func() { Expect(err).To(BeNil()) // Insert a fake migration into the database to simulate a downgrade - _, err = ConnectToDatabase(ctx, GinkgoT(), testServer.GetValue()). + _, err = ConnectToDatabase(ctx, GinkgoT(), connectionOptions). NewInsert(). ModelTableExpr(ledger.DefaultBucket + ".goose_db_version"). Model(&map[string]any{ @@ -279,7 +294,7 @@ var _ = Context("Ledger downgrade tests", func() { }) It("should be ok when targeting health check endpoint", func() { - ret, err := http.DefaultClient.Get(testservice.GetServerURL(testServer.GetValue()) + "/_healthcheck") + ret, err := http.DefaultClient.Get(testservice.GetServerURL(testServer.GetValue()).String() + "/_healthcheck") Expect(err).To(BeNil()) body := make(map[string]interface{}) diff --git a/test/e2e/app_logs_blocks_async_test.go b/test/e2e/app_logs_blocks_async_test.go index ca3d6dafdf..4f2778966c 100644 --- a/test/e2e/app_logs_blocks_async_test.go +++ b/test/e2e/app_logs_blocks_async_test.go @@ -6,6 +6,9 @@ import ( "fmt" "github.com/formancehq/go-libs/v2/logging" "github.com/formancehq/go-libs/v2/pointer" + "github.com/formancehq/go-libs/v2/testing/deferred" + "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" + "github.com/formancehq/go-libs/v2/testing/testservice" "github.com/formancehq/ledger/pkg/client/models/components" "github.com/formancehq/ledger/pkg/client/models/operations" "github.com/formancehq/ledger/pkg/features" @@ -18,8 +21,9 @@ import ( var _ = Context("Logs block async hashing", func() { var ( - db = UseTemplatedDatabase() - ctx = logging.TestingContext() + db = UseTemplatedDatabase() + connectionOptions = deferred.DeferMap(db, (*pgtesting.Database).ConnectionOptions) + ctx = logging.TestingContext() ) const ( @@ -28,20 +32,21 @@ var _ = Context("Logs block async hashing", func() { txCount = blockSize * nbBlock ) - testServer := DeferTestServer(debug, GinkgoWriter, func() ServeConfiguration { - return ServeConfiguration{ - PostgresConfiguration: PostgresConfiguration(db.GetValue().ConnectionOptions()), - NatsURL: natsServer.GetValue().ClientURL(), - ExperimentalFeatures: true, - } - }) - DeferTestWorker(debug, GinkgoWriter, func() WorkerConfiguration { - return WorkerConfiguration{ - PostgresConfiguration: PostgresConfiguration(db.GetValue().ConnectionOptions()), - LogsHashBlockMaxSize: blockSize, - LogsHashBlockCRONSpec: "* * * * * *", // every second - } - }) + testServer := DeferTestServer( + connectionOptions, + testservice.WithInstruments( + testservice.DebugInstrumentation(debug), + testservice.OutputInstrumentation(GinkgoWriter), + ExperimentalFeaturesInstrumentation(), + ), + testservice.WithLogger(GinkgoT()), + ) + + DeferTestWorker(connectionOptions, testservice.WithInstruments( + LogsHashBlockCRONSpecInstrumentation("* * * * * *"), + LogsHashBlockMaxSizeInstrumentation(blockSize), + )) + JustBeforeEach(func() { err := CreateLedger(ctx, testServer.GetValue(), operations.V2CreateLedgerRequest{ Ledger: "default", @@ -79,9 +84,8 @@ var _ = Context("Logs block async hashing", func() { Expect(err).To(BeNil()) }) It(fmt.Sprintf("should generate %d blocks", nbBlock), func() { + db := ConnectToDatabase(ctx, GinkgoT(), connectionOptions) Eventually(func(g Gomega) bool { - db := ConnectToDatabase(ctx, GinkgoT(), testServer.GetValue()) - ret := make([]map[string]any, 0) err := db.NewSelect(). Model(&ret). diff --git a/test/e2e/app_multiple_instance_test.go b/test/e2e/app_multiple_instance_test.go index 7ec1f8fb5e..780abc96e5 100644 --- a/test/e2e/app_multiple_instance_test.go +++ b/test/e2e/app_multiple_instance_test.go @@ -4,6 +4,7 @@ package test_suite import ( "github.com/formancehq/go-libs/v2/logging" + "github.com/formancehq/go-libs/v2/testing/deferred" "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" "github.com/formancehq/go-libs/v2/testing/testservice" "github.com/formancehq/ledger/cmd" @@ -22,9 +23,9 @@ var _ = Context("Ledger application multiple instance tests", func() { const nbServer = 3 When("starting multiple instances of the service", func() { - var allServers []*Server + var allServers []*testservice.Service BeforeEach(func() { - servers := make(chan *Server, nbServer) + servers := make(chan *testservice.Service, nbServer) wg := sync.WaitGroup{} wg.Add(nbServer) waitStart := make(chan struct{}) @@ -38,19 +39,10 @@ var _ = Context("Ledger application multiple instance tests", func() { testServer := testservice.New( cmd.NewRootCommand, - testservice.Configuration[ServeConfiguration]{ - CommonConfiguration: testservice.CommonConfiguration{ - Debug: debug, - Output: GinkgoWriter, - }, - Configuration: ServeConfiguration{ - PostgresConfiguration: PostgresConfiguration(db.GetValue().ConnectionOptions()), - NatsURL: natsServer.GetValue().ClientURL(), - DisableAutoUpgrade: true, - }, - }, + GetTestServerOptions(deferred.Map(db, (*pgtesting.Database).ConnectionOptions)), testservice.WithInstruments( - testservice.HTTPServerInstrumentation(), + testservice.DebugInstrumentation(debug), + testservice.OutputInstrumentation(GinkgoWriter), ), ) Expect(testServer.Start(ctx)).To(Succeed()) diff --git a/test/e2e/suite_test.go b/test/e2e/suite_test.go index f3286efeb5..09f6529d26 100644 --- a/test/e2e/suite_test.go +++ b/test/e2e/suite_test.go @@ -6,6 +6,7 @@ import ( "context" "encoding/json" "github.com/formancehq/go-libs/v2/bun/bunconnect" + "github.com/formancehq/go-libs/v2/testing/deferred" "github.com/formancehq/go-libs/v2/testing/platform/natstesting" ledger "github.com/formancehq/ledger/internal" "github.com/formancehq/ledger/internal/storage/bucket" @@ -16,7 +17,6 @@ import ( "github.com/formancehq/go-libs/v2/logging" "github.com/formancehq/go-libs/v2/testing/docker" . "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" - . "github.com/formancehq/go-libs/v2/testing/utils" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -27,9 +27,9 @@ func Test(t *testing.T) { } var ( - dockerPool = NewDeferred[*docker.Pool]() - pgServer = NewDeferred[*PostgresServer]() - natsServer = NewDeferred[*natstesting.NatsServer]() + dockerPool = deferred.New[*docker.Pool]() + pgServer = deferred.New[*PostgresServer]() + natsServer = deferred.New[*natstesting.NatsServer]() debug = os.Getenv("DEBUG") == "true" logger = logging.NewDefaultLogger(GinkgoWriter, debug, false, false) @@ -41,11 +41,13 @@ type ParallelExecutionContext struct { NatsServer *natstesting.NatsServer } -var _ = SynchronizedBeforeSuite(func() []byte { +var _ = SynchronizedBeforeSuite(func(specContext SpecContext) []byte { + deferred.RegisterRecoverHandler(GinkgoRecover) + By("Initializing docker pool") dockerPool.SetValue(docker.NewPool(GinkgoT(), logger)) - pgServer.LoadAsync(func() *PostgresServer { + pgServer.LoadAsync(func() (*PostgresServer, error) { By("Initializing postgres server") ret := CreatePostgresServer( GinkgoT(), @@ -70,17 +72,18 @@ var _ = SynchronizedBeforeSuite(func() []byte { Expect(bunDB.Close()).To(BeNil()) - return ret + return ret, nil }) - natsServer.LoadAsync(func() *natstesting.NatsServer { + + natsServer.LoadAsync(func() (*natstesting.NatsServer, error) { By("Initializing nats server") ret := natstesting.CreateServer(GinkgoT(), debug, logger) By("Nats address: " + ret.ClientURL()) - return ret + return ret, nil }) By("Waiting services alive") - Wait(pgServer, natsServer) + Expect(deferred.WaitContext(specContext, pgServer, natsServer)).To(BeNil()) By("All services ready.") data, err := json.Marshal(ParallelExecutionContext{ @@ -105,6 +108,6 @@ var _ = SynchronizedBeforeSuite(func() []byte { natsServer.SetValue(pec.NatsServer) }) -func UseTemplatedDatabase() *Deferred[*Database] { +func UseTemplatedDatabase() *deferred.Deferred[*Database] { return UsePostgresDatabase(pgServer, CreateWithTemplate(DBTemplate)) } diff --git a/test/e2e/v1_api_balances_test.go b/test/e2e/v1_api_balances_test.go index cc46a96599..17dffc5de1 100644 --- a/test/e2e/v1_api_balances_test.go +++ b/test/e2e/v1_api_balances_test.go @@ -6,6 +6,9 @@ import ( "fmt" "github.com/formancehq/go-libs/v2/logging" "github.com/formancehq/go-libs/v2/pointer" + "github.com/formancehq/go-libs/v2/testing/deferred" + "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" + "github.com/formancehq/go-libs/v2/testing/testservice" "github.com/formancehq/ledger/pkg/client/models/components" "github.com/formancehq/ledger/pkg/client/models/operations" . "github.com/formancehq/ledger/pkg/testserver" @@ -22,12 +25,14 @@ var _ = Context("Ledger accounts list API tests", func() { ctx = logging.TestingContext() ) - testServer := DeferTestServer(debug, GinkgoWriter, func() ServeConfiguration { - return ServeConfiguration{ - PostgresConfiguration: PostgresConfiguration(db.GetValue().ConnectionOptions()), - NatsURL: natsServer.GetValue().ClientURL(), - } - }) + testServer := DeferTestServer( + deferred.DeferMap(db, (*pgtesting.Database).ConnectionOptions), + testservice.WithInstruments( + testservice.DebugInstrumentation(debug), + testservice.OutputInstrumentation(GinkgoWriter), + ), + testservice.WithLogger(GinkgoT()), + ) BeforeEach(func() { err := CreateLedger(ctx, testServer.GetValue(), operations.V2CreateLedgerRequest{ Ledger: "default", diff --git a/test/performance/pkg/env/env.go b/test/performance/pkg/env/env.go index edde8fd34b..2b46129b32 100644 --- a/test/performance/pkg/env/env.go +++ b/test/performance/pkg/env/env.go @@ -10,7 +10,6 @@ import ( type Env interface { Client() *ledgerclient.Formance - URL() string Stop(ctx context.Context) error } diff --git a/test/performance/pkg/env/env_remote_ledger.go b/test/performance/pkg/env/env_remote_ledger.go index ecae5f82c2..0532c5d76c 100644 --- a/test/performance/pkg/env/env_remote_ledger.go +++ b/test/performance/pkg/env/env_remote_ledger.go @@ -15,13 +15,11 @@ type RemoteLedgerEnvFactory struct { ledgerURL string } -func (r *RemoteLedgerEnvFactory) Create(ctx context.Context, b *testing.B) Env { - client := ledgerclient.New( +func (r *RemoteLedgerEnvFactory) Create(_ context.Context, _ *testing.B) Env { + return NewRemoteLedgerEnv(ledgerclient.New( ledgerclient.WithClient(r.httpClient), ledgerclient.WithServerURL(r.ledgerURL), - ) - - return NewRemoteLedgerEnv(client, r.ledgerURL) + )) } var _ EnvFactory = (*RemoteLedgerEnvFactory)(nil) @@ -35,11 +33,6 @@ func NewRemoteLedgerEnvFactory(httpClient *http.Client, ledgerURL string) *Remot type RemoteLedgerEnv struct { client *ledgerclient.Formance - ledgerURL string -} - -func (r *RemoteLedgerEnv) URL() string { - return r.ledgerURL } func (r *RemoteLedgerEnv) Client() *ledgerclient.Formance { @@ -50,10 +43,9 @@ func (r *RemoteLedgerEnv) Stop(_ context.Context) error { return nil } -func NewRemoteLedgerEnv(client *ledgerclient.Formance, ledgerURL string) *RemoteLedgerEnv { +func NewRemoteLedgerEnv(client *ledgerclient.Formance) *RemoteLedgerEnv { return &RemoteLedgerEnv{ client: client, - ledgerURL: ledgerURL, } } diff --git a/test/performance/pkg/write/local_env_test.go b/test/performance/pkg/write/local_env_test.go index ca42b38d28..11ad7941cd 100644 --- a/test/performance/pkg/write/local_env_test.go +++ b/test/performance/pkg/write/local_env_test.go @@ -7,9 +7,12 @@ import ( "github.com/formancehq/go-libs/v2/logging" "github.com/formancehq/go-libs/v2/otlp/otlpmetrics" "github.com/formancehq/go-libs/v2/testing/docker" + "github.com/formancehq/go-libs/v2/testing/testservice" + . "github.com/formancehq/go-libs/v2/testing/utils" ledgerclient "github.com/formancehq/ledger/pkg/client" "github.com/formancehq/ledger/test/performance/pkg/env" "io" + "net/url" "os" "testing" @@ -19,15 +22,15 @@ import ( ) type TestServerEnv struct { - testServer *testserver.Server + testServer *testservice.Service } func (e *TestServerEnv) Client() *ledgerclient.Formance { - return e.testServer.Client() + return testserver.Client(e.testServer) } -func (e *TestServerEnv) URL() string { - return e.testServer.URL() +func (e *TestServerEnv) URL() *url.URL { + return testservice.GetServerURL(e.testServer) } func (e *TestServerEnv) Stop(ctx context.Context) error { @@ -58,20 +61,20 @@ func (f *TestServerEnvFactory) Create(ctx context.Context, b *testing.B) env.Env output = io.Discard } - testServer := testserver.New(b, testserver.ServeConfiguration{ - CommonConfiguration: testserver.CommonConfiguration{ - PostgresConfiguration: connectionOptions, - Debug: os.Getenv("DEBUG") == "true", - Output: output, - OTLPConfig: &testserver.OTLPConfig{ + testServer := testserver.NewTestServer( + NewValuedDeferred(connectionOptions), + testservice.WithInstruments( + testservice.DebugInstrumentation(os.Getenv("DEBUG") == "true"), + testservice.OutputInstrumentation(output), + testservice.OTLPInstrumentation(NewValuedDeferred(testservice.OTLPConfig{ Metrics: &otlpmetrics.ModuleConfig{ KeepInMemory: true, RuntimeMetrics: true, }, - }, - }, - ExperimentalFeatures: true, - }) + })), + testserver.ExperimentalFeaturesInstrumentation(), + ), + ) return &TestServerEnv{ testServer: testServer, diff --git a/test/stress/stress_test.go b/test/stress/stress_test.go index b25b636551..dfffa363ee 100644 --- a/test/stress/stress_test.go +++ b/test/stress/stress_test.go @@ -4,6 +4,8 @@ package test_suite import ( "fmt" + "github.com/formancehq/go-libs/v2/testing/deferred" + "github.com/formancehq/go-libs/v2/testing/testservice" "github.com/formancehq/ledger/pkg/features" "math/big" "math/rand" @@ -27,12 +29,12 @@ var _ = Context("Ledger stress tests", func() { ctx = logging.TestingContext() ) - testServer := DeferTestServer(debug, GinkgoWriter, func() ServeConfiguration { - return ServeConfiguration{ - PostgresConfiguration: PostgresConfiguration(db.GetValue().ConnectionOptions()), - ExperimentalFeatures: true, - } - }) + testServer := DeferTestServer( + deferred.DeferMap(db, (*pgtesting.Database).ConnectionOptions), + testservice.WithInstruments( + ExperimentalFeaturesInstrumentation(), + ), + ) const ( countLedgers = 6 diff --git a/test/stress/suite_test.go b/test/stress/suite_test.go index 810577ff16..111420812a 100644 --- a/test/stress/suite_test.go +++ b/test/stress/suite_test.go @@ -4,8 +4,8 @@ package test_suite import ( "encoding/json" + "github.com/formancehq/go-libs/v2/testing/deferred" . "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" - . "github.com/formancehq/go-libs/v2/testing/utils" "os" "testing" @@ -21,8 +21,8 @@ func Test(t *testing.T) { } var ( - dockerPool = NewDeferred[*docker.Pool]() - pgServer = NewDeferred[*PostgresServer]() + dockerPool = deferred.New[*docker.Pool]() + pgServer = deferred.New[*PostgresServer]() debug = os.Getenv("DEBUG") == "true" logger = logging.NewDefaultLogger(GinkgoWriter, debug, false, false) ) @@ -31,11 +31,11 @@ type ParallelExecutionContext struct { PostgresServer *PostgresServer } -var _ = SynchronizedBeforeSuite(func() []byte { +var _ = SynchronizedBeforeSuite(func(specContext SpecContext) []byte { By("Initializing docker pool") dockerPool.SetValue(docker.NewPool(GinkgoT(), logger)) - pgServer.LoadAsync(func() *PostgresServer { + pgServer.LoadAsync(func() (*PostgresServer, error) { By("Initializing postgres server") ret := CreatePostgresServer( GinkgoT(), @@ -44,11 +44,11 @@ var _ = SynchronizedBeforeSuite(func() []byte { WithPGCrypto(), ) By("Postgres address: " + ret.GetDSN()) - return ret + return ret, nil }) By("Waiting services alive") - Wait(pgServer) + Expect(deferred.WaitContext(specContext, pgServer)).To(BeNil()) By("All services ready.") data, err := json.Marshal(ParallelExecutionContext{ diff --git a/tools/generator/go.mod b/tools/generator/go.mod index 3699cf09e7..87e0e6b1e4 100644 --- a/tools/generator/go.mod +++ b/tools/generator/go.mod @@ -9,7 +9,7 @@ replace github.com/formancehq/ledger => ../.. replace github.com/formancehq/ledger/pkg/client => ../../pkg/client require ( - github.com/formancehq/go-libs/v2 v2.2.3-0.20250403104105-55a4f9b367d6 + github.com/formancehq/go-libs/v2 v2.2.3-0.20250404084034-ca6bcdb75003 github.com/formancehq/ledger v0.0.0-00010101000000-000000000000 github.com/formancehq/ledger/pkg/client v0.0.0-00010101000000-000000000000 github.com/spf13/cobra v1.9.1 diff --git a/tools/generator/go.sum b/tools/generator/go.sum index c38c250a53..729d67c455 100644 --- a/tools/generator/go.sum +++ b/tools/generator/go.sum @@ -102,8 +102,8 @@ github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= -github.com/formancehq/go-libs/v2 v2.2.3-0.20250403104105-55a4f9b367d6 h1:JmplOj1BMlJydMvE5ATVE4diLC+Wgt8rivkSEIocU0A= -github.com/formancehq/go-libs/v2 v2.2.3-0.20250403104105-55a4f9b367d6/go.mod h1:to6sgzwqspeTKlAF0Vdj/13EMHc8oYNc2gJfxf7hrt8= +github.com/formancehq/go-libs/v2 v2.2.3-0.20250404084034-ca6bcdb75003 h1:GEhD0mORxEGa9in2R/AKRLqubsdXYTjaxnNFEtT10FQ= +github.com/formancehq/go-libs/v2 v2.2.3-0.20250404084034-ca6bcdb75003/go.mod h1:to6sgzwqspeTKlAF0Vdj/13EMHc8oYNc2gJfxf7hrt8= github.com/formancehq/numscript v0.0.15 h1:dprjzbPWWPvIYM1o9P4Ppb6LKs4UuZw3AYeHy78b06k= github.com/formancehq/numscript v0.0.15/go.mod h1:P8qnq15PyWUuhskZdsrzTTqVS5CBkhakDKEPAyF4oYQ= github.com/fsnotify/fsnotify v1.8.0 h1:dAwr6QBTBZIkG8roQaJjGof0pp0EeF+tNV7YBP3F/8M= @@ -228,8 +228,8 @@ github.com/muhlemmer/gu v0.3.1 h1:7EAqmFrW7n3hETvuAdmFmn4hS8W+z3LgKtrnow+YzNM= github.com/muhlemmer/gu v0.3.1/go.mod h1:YHtHR+gxM+bKEIIs7Hmi9sPT3ZDUvTN/i88wQpZkrdM= github.com/muhlemmer/httpforwarded v0.1.0 h1:x4DLrzXdliq8mprgUMR0olDvHGkou5BJsK/vWUetyzY= github.com/muhlemmer/httpforwarded v0.1.0/go.mod h1:yo9czKedo2pdZhoXe+yDkGVbU0TJ0q9oQ90BVoDEtw0= -github.com/nats-io/nats.go v1.40.1 h1:MLjDkdsbGUeCMKFyCFoLnNn/HDTqcgVa3EQm+pMNDPk= -github.com/nats-io/nats.go v1.40.1/go.mod h1:wV73x0FSI/orHPSYoyMeJB+KajMDoWyXmFaRrrYaaTo= +github.com/nats-io/nats.go v1.41.0 h1:PzxEva7fflkd+n87OtQTXqCTyLfIIMFJBpyccHLE2Ko= +github.com/nats-io/nats.go v1.41.0/go.mod h1:wV73x0FSI/orHPSYoyMeJB+KajMDoWyXmFaRrrYaaTo= github.com/nats-io/nkeys v0.4.10 h1:glmRrpCmYLHByYcePvnTBEAwawwapjCPMjy2huw20wc= github.com/nats-io/nkeys v0.4.10/go.mod h1:OjRrnIKnWBFl+s4YK5ChQfvHP2fxqZexrKJoVVyWB3U= github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw= From 7e24697d3fc00983d2085a5db9a49fe1c5cf6017 Mon Sep 17 00:00:00 2001 From: Geoffrey Ragot Date: Fri, 4 Apr 2025 15:39:11 +0200 Subject: [PATCH 3/4] chore: simplify testserver --- go.mod | 2 +- go.sum | 4 +- pkg/generate/generator_test.go | 10 +- pkg/testserver/api.go | 248 --------------- pkg/testserver/client.go | 5 + pkg/testserver/ginkgo/helpers.go | 31 ++ pkg/testserver/{ => ginkgo}/matchers.go | 28 +- pkg/testserver/helpers.go | 88 ------ pkg/testserver/server.go | 19 ++ pkg/testserver/utils.go | 81 ++--- test/e2e/api_accounts_list_test.go | 143 ++++----- test/e2e/api_accounts_metadata_test.go | 61 ++-- test/e2e/api_balances_aggregated_test.go | 44 ++- test/e2e/api_bulk_test.go | 67 ++-- test/e2e/api_ledgers_create_test.go | 23 +- test/e2e/api_ledgers_import_test.go | 157 +++++----- test/e2e/api_ledgers_list_test.go | 41 +-- test/e2e/api_ledgers_metadata_test.go | 31 +- test/e2e/api_logs_list_test.go | 122 ++++---- test/e2e/api_transactions_create_test.go | 96 +++--- test/e2e/api_transactions_list_test.go | 348 +++++++++------------ test/e2e/api_transactions_metadata_test.go | 44 ++- test/e2e/api_transactions_revert_test.go | 123 ++++---- test/e2e/api_volumes_test.go | 71 ++--- test/e2e/app_lifecycle_test.go | 86 ++--- test/e2e/app_logs_blocks_async_test.go | 19 +- test/e2e/suite_test.go | 29 ++ test/e2e/v1_api_balances_test.go | 24 +- test/stress/stress_test.go | 19 +- tools/generator/go.mod | 2 +- tools/generator/go.sum | 6 +- 31 files changed, 889 insertions(+), 1183 deletions(-) delete mode 100644 pkg/testserver/api.go create mode 100644 pkg/testserver/ginkgo/helpers.go rename pkg/testserver/{ => ginkgo}/matchers.go (81%) delete mode 100644 pkg/testserver/helpers.go diff --git a/go.mod b/go.mod index 5e9d39aa74..c93a4e688e 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/antlr/antlr4/runtime/Go/antlr v1.4.10 github.com/bluele/gcache v0.0.2 github.com/dop251/goja v0.0.0-20241009100908-5f46f2705ca3 - github.com/formancehq/go-libs/v2 v2.2.3-0.20250404084034-ca6bcdb75003 + github.com/formancehq/go-libs/v2 v2.2.3-0.20250404150347-dfce43bb3362 github.com/formancehq/ledger/pkg/client v0.0.0-00010101000000-000000000000 github.com/go-chi/chi/v5 v5.2.1 github.com/go-chi/cors v1.2.1 diff --git a/go.sum b/go.sum index 7eae14b91f..b8c9d9c468 100644 --- a/go.sum +++ b/go.sum @@ -104,8 +104,8 @@ github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= -github.com/formancehq/go-libs/v2 v2.2.3-0.20250404084034-ca6bcdb75003 h1:GEhD0mORxEGa9in2R/AKRLqubsdXYTjaxnNFEtT10FQ= -github.com/formancehq/go-libs/v2 v2.2.3-0.20250404084034-ca6bcdb75003/go.mod h1:to6sgzwqspeTKlAF0Vdj/13EMHc8oYNc2gJfxf7hrt8= +github.com/formancehq/go-libs/v2 v2.2.3-0.20250404150347-dfce43bb3362 h1:UN4aVIj4qnzAeYEoz6mvWaAPWvx+CO+HXFEWac/8cv4= +github.com/formancehq/go-libs/v2 v2.2.3-0.20250404150347-dfce43bb3362/go.mod h1:to6sgzwqspeTKlAF0Vdj/13EMHc8oYNc2gJfxf7hrt8= github.com/formancehq/numscript v0.0.15 h1:dprjzbPWWPvIYM1o9P4Ppb6LKs4UuZw3AYeHy78b06k= github.com/formancehq/numscript v0.0.15/go.mod h1:P8qnq15PyWUuhskZdsrzTTqVS5CBkhakDKEPAyF4oYQ= github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= diff --git a/pkg/generate/generator_test.go b/pkg/generate/generator_test.go index f805663bb1..8f27f35924 100644 --- a/pkg/generate/generator_test.go +++ b/pkg/generate/generator_test.go @@ -56,17 +56,17 @@ func TestGenerator(t *testing.T) { require.NoError(t, err) } - txs, err := ListTransactions(ctx, testServer, operations.V2ListTransactionsRequest{ + txs, err := Client(testServer).Ledger.V2.ListTransactions(ctx, operations.V2ListTransactionsRequest{ Ledger: ledgerName, }) require.NoError(t, err) - require.Len(t, txs.Data, 2) - require.True(t, txs.Data[1].Reverted) - require.False(t, txs.Data[0].Reverted) + require.Len(t, txs.V2TransactionsCursorResponse.Cursor.Data, 2) + require.True(t, txs.V2TransactionsCursorResponse.Cursor.Data[1].Reverted) + require.False(t, txs.V2TransactionsCursorResponse.Cursor.Data[0].Reverted) require.Equal(t, map[string]string{ "foo": "bar", "globalMetadata": "test", - }, txs.Data[1].Metadata) + }, txs.V2TransactionsCursorResponse.Cursor.Data[1].Metadata) } const script = ` diff --git a/pkg/testserver/api.go b/pkg/testserver/api.go deleted file mode 100644 index 8ef2a5dfd5..0000000000 --- a/pkg/testserver/api.go +++ /dev/null @@ -1,248 +0,0 @@ -package testserver - -import ( - "bytes" - "context" - "github.com/formancehq/go-libs/v2/testing/testservice" - "io" - "math/big" - "strconv" - - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/ledger/pkg/client/models/components" - "github.com/formancehq/ledger/pkg/client/models/operations" - "github.com/formancehq/ledger/pkg/client/models/sdkerrors" -) - -func CreateLedger(ctx context.Context, srv *testservice.Service, request operations.V2CreateLedgerRequest) error { - _, err := Client(srv).Ledger.V2.CreateLedger(ctx, request) - return mapSDKError(err) -} - -func GetLedger(ctx context.Context, srv *testservice.Service, request operations.V2GetLedgerRequest) (*components.V2Ledger, error) { - ret, err := Client(srv).Ledger.V2.GetLedger(ctx, request) - if err := mapSDKError(err); err != nil { - return nil, err - } - return &ret.V2GetLedgerResponse.Data, nil -} - -func GetInfo(ctx context.Context, srv *testservice.Service) (*operations.V2GetInfoResponse, error) { - return Client(srv).Ledger.GetInfo(ctx) -} - -func GetLedgerInfo(ctx context.Context, srv *testservice.Service, request operations.V2GetLedgerInfoRequest) (*operations.V2GetLedgerInfoResponse, error) { - return Client(srv).Ledger.V2.GetLedgerInfo(ctx, request) -} - -func CreateTransaction(ctx context.Context, srv *testservice.Service, request operations.V2CreateTransactionRequest) (*components.V2Transaction, error) { - response, err := Client(srv).Ledger.V2.CreateTransaction(ctx, request) - - if err != nil { - return nil, mapSDKError(err) - } - - return &response.V2CreateTransactionResponse.Data, nil -} - -func CreateBulk(ctx context.Context, srv *testservice.Service, request operations.V2CreateBulkRequest) ([]components.V2BulkElementResult, error) { - response, err := Client(srv).Ledger.V2.CreateBulk(ctx, request) - if err != nil { - return nil, mapSDKError(err) - } - return response.V2BulkResponse.Data, nil -} - -func GetBalancesAggregated(ctx context.Context, srv *testservice.Service, request operations.V2GetBalancesAggregatedRequest) (map[string]*big.Int, error) { - response, err := Client(srv).Ledger.V2.GetBalancesAggregated(ctx, request) - if err != nil { - return nil, mapSDKError(err) - } - return response.V2AggregateBalancesResponse.Data, nil -} - -func GetVolumesWithBalances(ctx context.Context, srv *testservice.Service, request operations.V2GetVolumesWithBalancesRequest) (*components.V2VolumesWithBalanceCursorResponseCursor, error) { - response, err := Client(srv).Ledger.V2.GetVolumesWithBalances(ctx, request) - if err != nil { - return nil, mapSDKError(err) - } - return &response.V2VolumesWithBalanceCursorResponse.Cursor, nil -} - -func UpdateLedgerMetadata(ctx context.Context, srv *testservice.Service, request operations.V2UpdateLedgerMetadataRequest) error { - _, err := Client(srv).Ledger.V2.UpdateLedgerMetadata(ctx, request) - return mapSDKError(err) -} - -func DeleteLedgerMetadata(ctx context.Context, srv *testservice.Service, request operations.V2DeleteLedgerMetadataRequest) error { - _, err := Client(srv).Ledger.V2.DeleteLedgerMetadata(ctx, request) - return mapSDKError(err) -} - -func AddMetadataToAccount(ctx context.Context, srv *testservice.Service, request operations.V2AddMetadataToAccountRequest) error { - _, err := Client(srv).Ledger.V2.AddMetadataToAccount(ctx, request) - return mapSDKError(err) -} - -func AddMetadataToTransaction(ctx context.Context, srv *testservice.Service, request operations.V2AddMetadataOnTransactionRequest) error { - _, err := Client(srv).Ledger.V2.AddMetadataOnTransaction(ctx, request) - return mapSDKError(err) -} - -func DeleteAccountMetadata(ctx context.Context, srv *testservice.Service, request operations.V2DeleteAccountMetadataRequest) error { - _, err := Client(srv).Ledger.V2.DeleteAccountMetadata(ctx, request) - return mapSDKError(err) -} - -func DeleteTransactionMetadata(ctx context.Context, srv *testservice.Service, request operations.V2DeleteTransactionMetadataRequest) error { - _, err := Client(srv).Ledger.V2.DeleteTransactionMetadata(ctx, request) - return mapSDKError(err) -} - -func RevertTransaction(ctx context.Context, srv *testservice.Service, request operations.V2RevertTransactionRequest) (*components.V2Transaction, error) { - response, err := Client(srv).Ledger.V2.RevertTransaction(ctx, request) - - if err != nil { - return nil, mapSDKError(err) - } - - return &response.V2RevertTransactionResponse.Data, nil -} - -func GetTransaction(ctx context.Context, srv *testservice.Service, request operations.V2GetTransactionRequest) (*components.V2Transaction, error) { - response, err := Client(srv).Ledger.V2.GetTransaction(ctx, request) - - if err != nil { - return nil, mapSDKError(err) - } - - return &response.V2GetTransactionResponse.Data, nil -} - -func GetAccount(ctx context.Context, srv *testservice.Service, request operations.V2GetAccountRequest) (*components.V2Account, error) { - response, err := Client(srv).Ledger.V2.GetAccount(ctx, request) - - if err != nil { - return nil, mapSDKError(err) - } - - return &response.V2AccountResponse.Data, nil -} - -func ListTransactions(ctx context.Context, srv *testservice.Service, request operations.V2ListTransactionsRequest) (*components.V2TransactionsCursorResponseCursor, error) { - response, err := Client(srv).Ledger.V2.ListTransactions(ctx, request) - - if err != nil { - return nil, mapSDKError(err) - } - - return &response.V2TransactionsCursorResponse.Cursor, nil -} - -func CountTransactions(ctx context.Context, srv *testservice.Service, request operations.V2CountTransactionsRequest) (int, error) { - response, err := Client(srv).Ledger.V2.CountTransactions(ctx, request) - - if err != nil { - return 0, mapSDKError(err) - } - - ret, err := strconv.ParseInt(response.Headers["Count"][0], 10, 64) - if err != nil { - return 0, err - } - - return int(ret), nil -} - -func ListAccounts(ctx context.Context, srv *testservice.Service, request operations.V2ListAccountsRequest) (*components.V2AccountsCursorResponseCursor, error) { - response, err := Client(srv).Ledger.V2.ListAccounts(ctx, request) - - if err != nil { - return nil, mapSDKError(err) - } - - return &response.V2AccountsCursorResponse.Cursor, nil -} - -func ListLogs(ctx context.Context, srv *testservice.Service, request operations.V2ListLogsRequest) (*components.V2LogsCursorResponseCursor, error) { - response, err := Client(srv).Ledger.V2.ListLogs(ctx, request) - - if err != nil { - return nil, mapSDKError(err) - } - - return &response.V2LogsCursorResponse.Cursor, nil -} - -func CountAccounts(ctx context.Context, srv *testservice.Service, request operations.V2CountAccountsRequest) (int, error) { - response, err := Client(srv).Ledger.V2.CountAccounts(ctx, request) - - if err != nil { - return 0, mapSDKError(err) - } - - ret, err := strconv.ParseInt(response.Headers["Count"][0], 10, 64) - if err != nil { - return 0, err - } - - return int(ret), nil -} - -func ListLedgers(ctx context.Context, srv *testservice.Service, request operations.V2ListLedgersRequest) (*components.V2LedgerListResponseCursor, error) { - response, err := Client(srv).Ledger.V2.ListLedgers(ctx, request) - - if err != nil { - return nil, mapSDKError(err) - } - - return &response.V2LedgerListResponse.Cursor, nil -} - -func GetAggregatedBalances(ctx context.Context, srv *testservice.Service, request operations.V2GetBalancesAggregatedRequest) (map[string]*big.Int, error) { - response, err := Client(srv).Ledger.V2.GetBalancesAggregated(ctx, request) - - if err != nil { - return nil, mapSDKError(err) - } - - return response.GetV2AggregateBalancesResponse().Data, nil -} - -func Export(ctx context.Context, srv *testservice.Service, request operations.V2ExportLogsRequest) (io.Reader, error) { - response, err := Client(srv).Ledger.V2.ExportLogs(ctx, request) - if err != nil { - return nil, mapSDKError(err) - } - - data, err := io.ReadAll(response.HTTPMeta.Response.Body) - if err != nil { - return nil, err - } - - return bytes.NewBuffer(data), nil -} - -func Import(ctx context.Context, srv *testservice.Service, request operations.V2ImportLogsRequest) error { - _, err := Client(srv).Ledger.V2.ImportLogs(ctx, request) - return mapSDKError(err) -} - -func mapSDKError(err error) error { - // notes: *sdkerrors.V2ErrorResponse does not implements errors.Is - switch err := err.(type) { - case *sdkerrors.V2ErrorResponse: - return api.ErrorResponse{ - ErrorCode: string(err.ErrorCode), - ErrorMessage: err.ErrorMessage, - Details: func() string { - if err.Details == nil { - return "" - } - return *err.Details - }(), - } - default: - return err - } -} diff --git a/pkg/testserver/client.go b/pkg/testserver/client.go index 40eefab61a..c33ab7e025 100644 --- a/pkg/testserver/client.go +++ b/pkg/testserver/client.go @@ -1,6 +1,7 @@ package testserver import ( + "github.com/formancehq/go-libs/v2/testing/deferred" "github.com/formancehq/go-libs/v2/testing/testservice" ledgerclient "github.com/formancehq/ledger/pkg/client" ) @@ -10,3 +11,7 @@ func Client(srv *testservice.Service) *ledgerclient.Formance { ledgerclient.WithServerURL(testservice.GetServerURL(srv).String()), ) } + +func DeferClient(srv *deferred.Deferred[*testservice.Service]) *deferred.Deferred[*ledgerclient.Formance] { + return deferred.Map(srv, Client) +} diff --git a/pkg/testserver/ginkgo/helpers.go b/pkg/testserver/ginkgo/helpers.go new file mode 100644 index 0000000000..972f3de202 --- /dev/null +++ b/pkg/testserver/ginkgo/helpers.go @@ -0,0 +1,31 @@ +package ginkgo + +import ( + "github.com/formancehq/go-libs/v2/bun/bunconnect" + "github.com/formancehq/go-libs/v2/testing/deferred" + "github.com/formancehq/go-libs/v2/testing/testservice" + . "github.com/formancehq/go-libs/v2/testing/testservice/ginkgo" + "github.com/formancehq/ledger/cmd" + "github.com/formancehq/ledger/pkg/testserver" +) + +func DeferTestServer(postgresConnectionOptions *deferred.Deferred[bunconnect.ConnectionOptions], options ...testservice.Option) *deferred.Deferred[*testservice.Service] { + return DeferNew( + cmd.NewRootCommand, + append([]testservice.Option{ + testserver.GetTestServerOptions(postgresConnectionOptions), + }, options...)..., + ) +} + +func DeferTestWorker(postgresConnectionOptions *deferred.Deferred[bunconnect.ConnectionOptions], options ...testservice.Option) *deferred.Deferred[*testservice.Service] { + return DeferNew( + cmd.NewRootCommand, + append([]testservice.Option{ + testservice.WithInstruments( + testservice.AppendArgsInstrumentation("worker"), + testservice.PostgresInstrumentation(postgresConnectionOptions), + ), + }, options...)..., + ) +} diff --git a/pkg/testserver/matchers.go b/pkg/testserver/ginkgo/matchers.go similarity index 81% rename from pkg/testserver/matchers.go rename to pkg/testserver/ginkgo/matchers.go index ff2dc9ebdf..e4ebef05d0 100644 --- a/pkg/testserver/matchers.go +++ b/pkg/testserver/ginkgo/matchers.go @@ -1,4 +1,4 @@ -package testserver +package ginkgo import ( "context" @@ -7,8 +7,10 @@ import ( "fmt" "github.com/formancehq/go-libs/v2/pointer" "github.com/formancehq/go-libs/v2/publish" + "github.com/formancehq/go-libs/v2/testing/deferred" "github.com/formancehq/go-libs/v2/testing/testservice" "github.com/formancehq/ledger/pkg/client/models/operations" + "github.com/formancehq/ledger/pkg/testserver" "github.com/google/go-cmp/cmp" "github.com/invopop/jsonschema" "github.com/nats-io/nats.go" @@ -22,35 +24,41 @@ import ( type HaveCoherentStateMatcher struct{} func (h HaveCoherentStateMatcher) Match(actual interface{}) (success bool, err error) { - srv, ok := actual.(*testservice.Service) + d, ok := actual.(*deferred.Deferred[*testservice.Service]) if !ok { return false, fmt.Errorf("expect type %T", new(testservice.Service)) } ctx := context.Background() - ledgers, err := ListLedgers(ctx, srv, operations.V2ListLedgersRequest{ + testServer, err := d.Wait(context.Background()) + if err != nil { + return false, err + } + client := testserver.Client(testServer).Ledger.V2 + + ledgers, err := client.ListLedgers(ctx, operations.V2ListLedgersRequest{ PageSize: pointer.For(int64(100)), }) if err != nil { return false, err } - for _, ledger := range ledgers.Data { - aggregatedBalances, err := GetAggregatedBalances(ctx, srv, operations.V2GetBalancesAggregatedRequest{ + for _, ledger := range ledgers.V2LedgerListResponse.Cursor.Data { + aggregatedBalances, err := client.GetBalancesAggregated(ctx, operations.V2GetBalancesAggregatedRequest{ Ledger: ledger.Name, UseInsertionDate: pointer.For(true), }) Expect(err).To(BeNil()) - if len(aggregatedBalances) == 0 { // it's random, a ledger could not have been targeted + if len(aggregatedBalances.V2AggregateBalancesResponse.Data) == 0 { // it's random, a ledger could not have been targeted // just in case, check if the ledger has transactions - txs, err := ListTransactions(ctx, srv, operations.V2ListTransactionsRequest{ + txs, err := client.ListTransactions(ctx, operations.V2ListTransactionsRequest{ Ledger: ledger.Name, }) Expect(err).To(BeNil()) - Expect(txs.Data).To(HaveLen(0)) + Expect(txs.V2TransactionsCursorResponse.Cursor.Data).To(HaveLen(0)) } else { - Expect(aggregatedBalances).To(HaveLen(1)) - Expect(aggregatedBalances["USD"]).To(Equal(big.NewInt(0))) + Expect(aggregatedBalances.V2AggregateBalancesResponse.Data).To(HaveLen(1)) + Expect(aggregatedBalances.V2AggregateBalancesResponse.Data["USD"]).To(Equal(big.NewInt(0))) } } diff --git a/pkg/testserver/helpers.go b/pkg/testserver/helpers.go deleted file mode 100644 index 0326125928..0000000000 --- a/pkg/testserver/helpers.go +++ /dev/null @@ -1,88 +0,0 @@ -package testserver - -import ( - "context" - "github.com/formancehq/go-libs/v2/bun/bunconnect" - "github.com/formancehq/go-libs/v2/collectionutils" - "github.com/formancehq/go-libs/v2/pointer" - "github.com/formancehq/go-libs/v2/testing/deferred" - "github.com/formancehq/go-libs/v2/testing/testservice" - "github.com/formancehq/go-libs/v2/time" - "github.com/formancehq/ledger/internal" - "github.com/formancehq/ledger/pkg/client/models/components" - "github.com/nats-io/nats.go" - "github.com/stretchr/testify/require" - "github.com/uptrace/bun" -) - -func ConvertSDKTxToCoreTX(tx *components.V2Transaction) ledger.Transaction { - return ledger.Transaction{ - TransactionData: ledger.TransactionData{ - Postings: collectionutils.Map(tx.Postings, ConvertSDKPostingToCorePosting), - Timestamp: time.New(tx.Timestamp), - InsertedAt: time.New(*tx.InsertedAt), - Metadata: tx.Metadata, - Reference: func() string { - if tx.Reference == nil { - return "" - } - return *tx.Reference - }(), - }, - ID: pointer.For(int(tx.ID.Int64())), - PostCommitVolumes: ConvertSDKPostCommitVolumesToCorePostCommitVolumes(tx.PostCommitVolumes), - PostCommitEffectiveVolumes: ConvertSDKPostCommitVolumesToCorePostCommitVolumes(tx.PostCommitEffectiveVolumes), - } -} - -func ConvertSDKPostCommitVolumesToCorePostCommitVolumes(volumes map[string]map[string]components.V2Volume) ledger.PostCommitVolumes { - ret := ledger.PostCommitVolumes{} - for account, volumesByAsset := range volumes { - for asset, volumes := range volumesByAsset { - ret.Merge(ledger.PostCommitVolumes{ - account: { - asset: ledger.Volumes{ - Input: volumes.Input, - Output: volumes.Output, - }, - }, - }) - } - } - return ret -} - -func ConvertSDKPostingToCorePosting(p components.V2Posting) ledger.Posting { - return ledger.Posting{ - Source: p.Source, - Destination: p.Destination, - Asset: p.Asset, - Amount: p.Amount, - } -} - -func ConnectToDatabase(ctx context.Context, t interface { - require.TestingT - Cleanup(func()) -}, dbOptions *deferred.Deferred[bunconnect.ConnectionOptions]) *bun.DB { - db, err := bunconnect.OpenSQLDB(ctx, dbOptions.GetValue()) - require.NoError(t, err) - - t.Cleanup(func() { - require.NoError(t, db.Close()) - }) - return db -} - -func Subscribe(t require.TestingT, srv *testservice.Service, natsURL *deferred.Deferred[string]) (*nats.Subscription, chan *nats.Msg) { - ret := make(chan *nats.Msg) - conn, err := nats.Connect(natsURL.GetValue()) - require.NoError(t, err) - - subscription, err := conn.Subscribe(srv.GetID(), func(msg *nats.Msg) { - ret <- msg - }) - require.NoError(t, err) - - return subscription, ret -} diff --git a/pkg/testserver/server.go b/pkg/testserver/server.go index 1270cb1bf6..eaadefbb8f 100644 --- a/pkg/testserver/server.go +++ b/pkg/testserver/server.go @@ -3,10 +3,29 @@ package testserver import ( "context" "fmt" + "github.com/formancehq/go-libs/v2/bun/bunconnect" + "github.com/formancehq/go-libs/v2/testing/deferred" "github.com/formancehq/go-libs/v2/testing/testservice" "github.com/formancehq/ledger/cmd" ) +func GetTestServerOptions(postgresConnectionOptions *deferred.Deferred[bunconnect.ConnectionOptions]) testservice.Option { + return testservice.WithInstruments( + testservice.AppendArgsInstrumentation("serve", "--"+cmd.BindFlag, ":0"), + testservice.PostgresInstrumentation(postgresConnectionOptions), + testservice.HTTPServerInstrumentation(), + ) +} + +func NewTestServer(postgresConnectionOptions *deferred.Deferred[bunconnect.ConnectionOptions], options ...testservice.Option) *testservice.Service { + return testservice.New( + cmd.NewRootCommand, + append([]testservice.Option{ + GetTestServerOptions(postgresConnectionOptions), + }, options...)..., + ) +} + func ExperimentalFeaturesInstrumentation() testservice.InstrumentationFunc { return func(ctx context.Context, runConfiguration *testservice.RunConfiguration) error { runConfiguration.AppendArgs("--" + cmd.ExperimentalFeaturesFlag) diff --git a/pkg/testserver/utils.go b/pkg/testserver/utils.go index 455ecb85e5..b95be84db3 100644 --- a/pkg/testserver/utils.go +++ b/pkg/testserver/utils.go @@ -1,46 +1,55 @@ package testserver import ( - "github.com/formancehq/go-libs/v2/bun/bunconnect" - "github.com/formancehq/go-libs/v2/testing/deferred" - "github.com/formancehq/go-libs/v2/testing/testservice" - "github.com/formancehq/ledger/cmd" + "github.com/formancehq/go-libs/v2/collectionutils" + "github.com/formancehq/go-libs/v2/pointer" + "github.com/formancehq/go-libs/v2/time" + ledger "github.com/formancehq/ledger/internal" + "github.com/formancehq/ledger/pkg/client/models/components" ) -func GetTestServerOptions(postgresConnectionOptions *deferred.Deferred[bunconnect.ConnectionOptions]) testservice.Option { - return testservice.WithInstruments( - testservice.AppendArgsInstrumentation("serve", "--"+cmd.BindFlag, ":0"), - testservice.PostgresInstrumentation(postgresConnectionOptions), - testservice.HTTPServerInstrumentation(), - ) +func ConvertSDKTxToCoreTX(tx *components.V2Transaction) ledger.Transaction { + return ledger.Transaction{ + TransactionData: ledger.TransactionData{ + Postings: collectionutils.Map(tx.Postings, ConvertSDKPostingToCorePosting), + Timestamp: time.New(tx.Timestamp), + InsertedAt: time.New(*tx.InsertedAt), + Metadata: tx.Metadata, + Reference: func() string { + if tx.Reference == nil { + return "" + } + return *tx.Reference + }(), + }, + ID: pointer.For(int(tx.ID.Int64())), + PostCommitVolumes: ConvertSDKPostCommitVolumesToCorePostCommitVolumes(tx.PostCommitVolumes), + PostCommitEffectiveVolumes: ConvertSDKPostCommitVolumesToCorePostCommitVolumes(tx.PostCommitEffectiveVolumes), + } } -func DeferTestServer(postgresConnectionOptions *deferred.Deferred[bunconnect.ConnectionOptions], options ...testservice.Option) *deferred.Deferred[*testservice.Service] { - return testservice.DeferNew( - cmd.NewRootCommand, - append([]testservice.Option{ - GetTestServerOptions(postgresConnectionOptions), - }, options...)..., - ) +func ConvertSDKPostCommitVolumesToCorePostCommitVolumes(volumes map[string]map[string]components.V2Volume) ledger.PostCommitVolumes { + ret := ledger.PostCommitVolumes{} + for account, volumesByAsset := range volumes { + for asset, volumes := range volumesByAsset { + ret.Merge(ledger.PostCommitVolumes{ + account: { + asset: ledger.Volumes{ + Input: volumes.Input, + Output: volumes.Output, + }, + }, + }) + } + } + return ret } -func NewTestServer(postgresConnectionOptions *deferred.Deferred[bunconnect.ConnectionOptions], options ...testservice.Option) *testservice.Service { - return testservice.New( - cmd.NewRootCommand, - append([]testservice.Option{ - GetTestServerOptions(postgresConnectionOptions), - }, options...)..., - ) -} - -func DeferTestWorker(postgresConnectionOptions *deferred.Deferred[bunconnect.ConnectionOptions], options ...testservice.Option) *deferred.Deferred[*testservice.Service] { - return testservice.DeferNew( - cmd.NewRootCommand, - append([]testservice.Option{ - testservice.WithInstruments( - testservice.AppendArgsInstrumentation("worker"), - testservice.PostgresInstrumentation(postgresConnectionOptions), - ), - }, options...)..., - ) +func ConvertSDKPostingToCorePosting(p components.V2Posting) ledger.Posting { + return ledger.Posting{ + Source: p.Source, + Destination: p.Destination, + Asset: p.Asset, + Amount: p.Amount, + } } diff --git a/test/e2e/api_accounts_list_test.go b/test/e2e/api_accounts_list_test.go index fee662fb3c..7baeffdf84 100644 --- a/test/e2e/api_accounts_list_test.go +++ b/test/e2e/api_accounts_list_test.go @@ -6,13 +6,14 @@ import ( "fmt" "github.com/formancehq/go-libs/v2/logging" . "github.com/formancehq/go-libs/v2/testing/api" - "github.com/formancehq/go-libs/v2/testing/deferred" + . "github.com/formancehq/go-libs/v2/testing/deferred/ginkgo" "github.com/formancehq/go-libs/v2/testing/platform/natstesting" "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" "github.com/formancehq/go-libs/v2/testing/testservice" "github.com/formancehq/ledger/pkg/client/models/components" "github.com/formancehq/ledger/pkg/client/models/operations" . "github.com/formancehq/ledger/pkg/testserver" + "github.com/formancehq/ledger/pkg/testserver/ginkgo" "math/big" "sort" "time" @@ -30,18 +31,18 @@ var _ = Context("Ledger accounts list API tests", func() { ctx = logging.TestingContext() ) - testServer := DeferTestServer( - deferred.DeferMap(db, (*pgtesting.Database).ConnectionOptions), + testServer := ginkgo.DeferTestServer( + DeferMap(db, (*pgtesting.Database).ConnectionOptions), testservice.WithInstruments( - testservice.NatsInstrumentation(deferred.DeferMap(natsServer, (*natstesting.NatsServer).ClientURL)), + testservice.NatsInstrumentation(DeferMap(natsServer, (*natstesting.NatsServer).ClientURL)), testservice.DebugInstrumentation(debug), testservice.OutputInstrumentation(GinkgoWriter), ), testservice.WithLogger(GinkgoT()), ) - BeforeEach(func() { - err := CreateLedger(ctx, testServer.GetValue(), operations.V2CreateLedgerRequest{ + BeforeEach(func(specContext SpecContext) { + _, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.CreateLedger(ctx, operations.V2CreateLedgerRequest{ Ledger: "default", }) Expect(err).To(BeNil()) @@ -59,10 +60,9 @@ var _ = Context("Ledger accounts list API tests", func() { timestamp = time.Now().Round(time.Second).UTC() bigInt, _ = big.NewInt(0).SetString("999999999999999999999999999999999999999999999999999999999999999999999999999999999999999", 10) ) - BeforeEach(func() { - err := AddMetadataToAccount( + BeforeEach(func(specContext SpecContext) { + _, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.AddMetadataToAccount( ctx, - testServer.GetValue(), operations.V2AddMetadataToAccountRequest{ RequestBody: metadata1, Address: "foo:foo", @@ -71,9 +71,8 @@ var _ = Context("Ledger accounts list API tests", func() { ) Expect(err).ToNot(HaveOccurred()) - err = AddMetadataToAccount( + _, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.AddMetadataToAccount( ctx, - testServer.GetValue(), operations.V2AddMetadataToAccountRequest{ RequestBody: metadata2, Address: "foo:bar", @@ -82,9 +81,8 @@ var _ = Context("Ledger accounts list API tests", func() { ) Expect(err).ToNot(HaveOccurred()) - _, err = CreateTransaction( + _, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.CreateTransaction( ctx, - testServer.GetValue(), operations.V2CreateTransactionRequest{ V2PostTransaction: components.V2PostTransaction{ Metadata: map[string]string{}, @@ -101,10 +99,9 @@ var _ = Context("Ledger accounts list API tests", func() { ) Expect(err).ToNot(HaveOccurred()) }) - It("should return a "+string(components.V2ErrorsEnumValidation)+" on invalid filter", func() { - _, err := ListAccounts( + It("should return a "+string(components.V2ErrorsEnumValidation)+" on invalid filter", func(specContext SpecContext) { + _, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.ListAccounts( ctx, - testServer.GetValue(), operations.V2ListAccountsRequest{ Ledger: "default", RequestBody: map[string]interface{}{ @@ -117,21 +114,19 @@ var _ = Context("Ledger accounts list API tests", func() { Expect(err).To(HaveOccurred()) Expect(err).To(HaveErrorCode(string(components.V2ErrorsEnumValidation))) }) - It("should be countable on api", func() { - response, err := CountAccounts( + It("should be countable on api", func(specContext SpecContext) { + response, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.CountAccounts( ctx, - testServer.GetValue(), operations.V2CountAccountsRequest{ Ledger: "default", }, ) Expect(err).ToNot(HaveOccurred()) - Expect(response).To(Equal(3)) + Expect(response.Headers["Count"]).To(Equal([]string{"3"})) }) - It("should be listed on api", func() { - response, err := ListAccounts( + It("should be listed on api", func(specContext SpecContext) { + response, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.ListAccounts( ctx, - testServer.GetValue(), operations.V2ListAccountsRequest{ Ledger: "default", Expand: pointer.For("volumes"), @@ -139,7 +134,7 @@ var _ = Context("Ledger accounts list API tests", func() { ) Expect(err).ToNot(HaveOccurred()) - accountsCursorResponse := response.Data + accountsCursorResponse := response.V2AccountsCursorResponse.Cursor.Data Expect(accountsCursorResponse).To(HaveLen(3)) Expect(accountsCursorResponse[0]).To(Equal(components.V2Account{ Address: "foo:bar", @@ -168,10 +163,9 @@ var _ = Context("Ledger accounts list API tests", func() { }, })) }) - It("should be listed on api using address filters", func() { - response, err := ListAccounts( + It("should be listed on api using address filters", func(specContext SpecContext) { + response, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.ListAccounts( ctx, - testServer.GetValue(), operations.V2ListAccountsRequest{ Ledger: "default", RequestBody: map[string]interface{}{ @@ -183,7 +177,7 @@ var _ = Context("Ledger accounts list API tests", func() { ) Expect(err).ToNot(HaveOccurred()) - accountsCursorResponse := response.Data + accountsCursorResponse := response.V2AccountsCursorResponse.Cursor.Data Expect(accountsCursorResponse).To(HaveLen(2)) Expect(accountsCursorResponse[0]).To(Equal(components.V2Account{ Address: "foo:bar", @@ -194,9 +188,8 @@ var _ = Context("Ledger accounts list API tests", func() { Metadata: metadata1, })) - response, err = ListAccounts( + response, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.ListAccounts( ctx, - testServer.GetValue(), operations.V2ListAccountsRequest{ Ledger: "default", RequestBody: map[string]interface{}{ @@ -208,17 +201,16 @@ var _ = Context("Ledger accounts list API tests", func() { ) Expect(err).ToNot(HaveOccurred()) - accountsCursorResponse = response.Data + accountsCursorResponse = response.V2AccountsCursorResponse.Cursor.Data Expect(accountsCursorResponse).To(HaveLen(1)) Expect(accountsCursorResponse[0]).To(Equal(components.V2Account{ Address: "foo:foo", Metadata: metadata1, })) }) - It("should be listed on api using metadata filters", func() { - response, err := ListAccounts( + It("should be listed on api using metadata filters", func(specContext SpecContext) { + response, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.ListAccounts( ctx, - testServer.GetValue(), operations.V2ListAccountsRequest{ Ledger: "default", RequestBody: map[string]interface{}{ @@ -230,17 +222,16 @@ var _ = Context("Ledger accounts list API tests", func() { ) Expect(err).ToNot(HaveOccurred()) - accountsCursorResponse := response.Data + accountsCursorResponse := response.V2AccountsCursorResponse.Cursor.Data Expect(accountsCursorResponse).To(HaveLen(1)) Expect(accountsCursorResponse[0]).To(Equal(components.V2Account{ Address: "foo:foo", Metadata: metadata1, })) }) - It("should be listable on api using $not filter", func() { - response, err := ListAccounts( + It("should be listable on api using $not filter", func(specContext SpecContext) { + response, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.ListAccounts( ctx, - testServer.GetValue(), operations.V2ListAccountsRequest{ Ledger: "default", RequestBody: map[string]interface{}{ @@ -254,33 +245,31 @@ var _ = Context("Ledger accounts list API tests", func() { ) Expect(err).ToNot(HaveOccurred()) - accountsCursorResponse := response.Data + accountsCursorResponse := response.V2AccountsCursorResponse.Cursor.Data Expect(accountsCursorResponse).To(HaveLen(2)) }) }) When("counting and listing accounts empty", func() { - It("should be countable on api even if empty", func() { - response, err := CountAccounts( + It("should be countable on api even if empty", func(specContext SpecContext) { + response, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.CountAccounts( ctx, - testServer.GetValue(), operations.V2CountAccountsRequest{ Ledger: "default", }, ) Expect(err).ToNot(HaveOccurred()) - Expect(response).To(Equal(0)) + Expect(response.Headers["Count"]).To(Equal([]string{"0"})) }) - It("should be listed on api even if empty", func() { - response, err := ListAccounts( + It("should be listed on api even if empty", func(specContext SpecContext) { + response, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.ListAccounts( ctx, - testServer.GetValue(), operations.V2ListAccountsRequest{ Ledger: "default", }, ) Expect(err).ToNot(HaveOccurred()) - Expect(response.Data).To(HaveLen(0)) + Expect(response.V2AccountsCursorResponse.Cursor.Data).To(HaveLen(0)) }) }) @@ -292,15 +281,14 @@ var _ = Context("Ledger accounts list API tests", func() { var ( accounts []components.V2Account ) - BeforeEach(func() { + BeforeEach(func(specContext SpecContext) { for i := 0; i < int(accountCounts); i++ { m := map[string]string{ "id": fmt.Sprintf("%d", i), } - err := AddMetadataToAccount( + _, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.AddMetadataToAccount( ctx, - testServer.GetValue(), operations.V2AddMetadataToAccountRequest{ RequestBody: m, Address: fmt.Sprintf("foo:%d", i), @@ -324,13 +312,12 @@ var _ = Context("Ledger accounts list API tests", func() { }) When(fmt.Sprintf("listing accounts using page size of %d", pageSize), func() { var ( - response *components.V2AccountsCursorResponseCursor + response *operations.V2ListAccountsResponse err error ) - BeforeEach(func() { - response, err = ListAccounts( + BeforeEach(func(specContext SpecContext) { + response, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.ListAccounts( ctx, - testServer.GetValue(), operations.V2ListAccountsRequest{ Ledger: "default", PageSize: pointer.For(pageSize), @@ -338,47 +325,45 @@ var _ = Context("Ledger accounts list API tests", func() { ) Expect(err).ToNot(HaveOccurred()) - Expect(response.HasMore).To(BeTrue()) - Expect(response.Previous).To(BeNil()) - Expect(response.Next).NotTo(BeNil()) + Expect(response.V2AccountsCursorResponse.Cursor.HasMore).To(BeTrue()) + Expect(response.V2AccountsCursorResponse.Cursor.Previous).To(BeNil()) + Expect(response.V2AccountsCursorResponse.Cursor.Next).NotTo(BeNil()) }) It("should return the first page", func() { - Expect(response.PageSize).To(Equal(pageSize)) - Expect(response.Data).To(Equal(accounts[:pageSize])) + Expect(response.V2AccountsCursorResponse.Cursor.PageSize).To(Equal(pageSize)) + Expect(response.V2AccountsCursorResponse.Cursor.Data).To(Equal(accounts[:pageSize])) }) When("following next cursor", func() { - BeforeEach(func() { - response, err = ListAccounts( + BeforeEach(func(specContext SpecContext) { + response, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.ListAccounts( ctx, - testServer.GetValue(), operations.V2ListAccountsRequest{ - Cursor: response.Next, + Cursor: response.V2AccountsCursorResponse.Cursor.Next, Ledger: "default", }, ) Expect(err).ToNot(HaveOccurred()) }) It("should return next page", func() { - Expect(response.PageSize).To(Equal(pageSize)) - Expect(response.Data).To(Equal(accounts[pageSize : 2*pageSize])) - Expect(response.Next).To(BeNil()) + Expect(response.V2AccountsCursorResponse.Cursor.PageSize).To(Equal(pageSize)) + Expect(response.V2AccountsCursorResponse.Cursor.Data).To(Equal(accounts[pageSize : 2*pageSize])) + Expect(response.V2AccountsCursorResponse.Cursor.Next).To(BeNil()) }) When("following previous cursor", func() { - BeforeEach(func() { - response, err = ListAccounts( + BeforeEach(func(specContext SpecContext) { + response, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.ListAccounts( ctx, - testServer.GetValue(), operations.V2ListAccountsRequest{ Ledger: "default", - Cursor: response.Previous, + Cursor: response.V2AccountsCursorResponse.Cursor.Previous, }, ) Expect(err).ToNot(HaveOccurred()) }) It("should return first page", func() { - Expect(response.PageSize).To(Equal(pageSize)) - Expect(response.Data).To(Equal(accounts[:pageSize])) - Expect(response.Previous).To(BeNil()) + Expect(response.V2AccountsCursorResponse.Cursor.PageSize).To(Equal(pageSize)) + Expect(response.V2AccountsCursorResponse.Cursor.Data).To(Equal(accounts[:pageSize])) + Expect(response.V2AccountsCursorResponse.Cursor.Previous).To(BeNil()) }) }) }) @@ -387,8 +372,8 @@ var _ = Context("Ledger accounts list API tests", func() { When("Inserting one transaction in past and one in the future", func() { now := time.Now() - BeforeEach(func() { - _, err := CreateTransaction(ctx, testServer.GetValue(), operations.V2CreateTransactionRequest{ + BeforeEach(func(specContext SpecContext) { + _, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.CreateTransaction(ctx, operations.V2CreateTransactionRequest{ V2PostTransaction: components.V2PostTransaction{ Postings: []components.V2Posting{{ Amount: big.NewInt(100), @@ -403,7 +388,7 @@ var _ = Context("Ledger accounts list API tests", func() { }) Expect(err).To(Succeed()) - _, err = CreateTransaction(ctx, testServer.GetValue(), operations.V2CreateTransactionRequest{ + _, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.CreateTransaction(ctx, operations.V2CreateTransactionRequest{ V2PostTransaction: components.V2PostTransaction{ Postings: []components.V2Posting{{ Amount: big.NewInt(100), @@ -419,15 +404,15 @@ var _ = Context("Ledger accounts list API tests", func() { Expect(err).To(Succeed()) }) When("getting account in the present", func() { - It("should ignore future transaction on effective volumes", func() { - accountResponse, err := GetAccount(ctx, testServer.GetValue(), operations.V2GetAccountRequest{ + It("should ignore future transaction on effective volumes", func(specContext SpecContext) { + accountResponse, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.GetAccount(ctx, operations.V2GetAccountRequest{ Address: "foo", Expand: pointer.For("effectiveVolumes"), Ledger: "default", Pit: pointer.For(time.Now().Add(time.Minute)), }) Expect(err).To(Succeed()) - Expect(accountResponse.EffectiveVolumes["USD"].Balance).To(Equal(big.NewInt(100))) + Expect(accountResponse.V2AccountResponse.Data.EffectiveVolumes["USD"].Balance).To(Equal(big.NewInt(100))) }) }) }) diff --git a/test/e2e/api_accounts_metadata_test.go b/test/e2e/api_accounts_metadata_test.go index 49afcab471..90e3afc8e0 100644 --- a/test/e2e/api_accounts_metadata_test.go +++ b/test/e2e/api_accounts_metadata_test.go @@ -4,7 +4,8 @@ package test_suite import ( "github.com/formancehq/go-libs/v2/logging" - "github.com/formancehq/go-libs/v2/testing/deferred" + "github.com/formancehq/go-libs/v2/testing/deferred/ginkgo" + . "github.com/formancehq/go-libs/v2/testing/deferred/ginkgo" "github.com/formancehq/go-libs/v2/testing/platform/natstesting" "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" "github.com/formancehq/go-libs/v2/testing/testservice" @@ -12,6 +13,7 @@ import ( "github.com/formancehq/ledger/pkg/client/models/operations" ledgerevents "github.com/formancehq/ledger/pkg/events" . "github.com/formancehq/ledger/pkg/testserver" + . "github.com/formancehq/ledger/pkg/testserver/ginkgo" "github.com/nats-io/nats.go" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -19,13 +21,13 @@ import ( var _ = Context("Ledger accounts metadata API tests", func() { var ( - db = UseTemplatedDatabase() - ctx = logging.TestingContext() - natsURL = deferred.DeferMap(natsServer, (*natstesting.NatsServer).ClientURL) + db = UseTemplatedDatabase() + ctx = logging.TestingContext() + natsURL = ginkgo.DeferMap(natsServer, (*natstesting.NatsServer).ClientURL) ) testServer := DeferTestServer( - deferred.DeferMap(db, (*pgtesting.Database).ConnectionOptions), + ginkgo.DeferMap(db, (*pgtesting.Database).ConnectionOptions), testservice.WithInstruments( testservice.NatsInstrumentation(natsURL), testservice.DebugInstrumentation(debug), @@ -34,12 +36,12 @@ var _ = Context("Ledger accounts metadata API tests", func() { testservice.WithLogger(GinkgoT()), ) var events chan *nats.Msg - BeforeEach(func() { - _, events = Subscribe(GinkgoT(), testServer.GetValue(), natsURL) + BeforeEach(func(specContext SpecContext) { + _, events = Subscribe(specContext, testServer, natsURL) }) - BeforeEach(func() { - err := CreateLedger(ctx, testServer.GetValue(), operations.V2CreateLedgerRequest{ + BeforeEach(func(specContext SpecContext) { + _, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.CreateLedger(ctx, operations.V2CreateLedgerRequest{ Ledger: "default", }) Expect(err).To(BeNil()) @@ -50,10 +52,9 @@ var _ = Context("Ledger accounts metadata API tests", func() { "clientType": "gold", } ) - JustBeforeEach(func() { - err := AddMetadataToAccount( + JustBeforeEach(func(specContext SpecContext) { + _, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.AddMetadataToAccount( ctx, - testServer.GetValue(), operations.V2AddMetadataToAccountRequest{ RequestBody: metadata, Address: "foo", @@ -62,10 +63,9 @@ var _ = Context("Ledger accounts metadata API tests", func() { ) Expect(err).ToNot(HaveOccurred()) }) - It("should be available on api", func() { - response, err := GetAccount( + It("should be available on api", func(specContext SpecContext) { + response, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.GetAccount( ctx, - testServer.GetValue(), operations.V2GetAccountRequest{ Address: "foo", Ledger: "default", @@ -73,7 +73,7 @@ var _ = Context("Ledger accounts metadata API tests", func() { ) Expect(err).ToNot(HaveOccurred()) - Expect(*response).Should(Equal(components.V2Account{ + Expect(response.V2AccountResponse.Data).Should(Equal(components.V2Account{ Address: "foo", Metadata: metadata, })) @@ -84,10 +84,9 @@ var _ = Context("Ledger accounts metadata API tests", func() { "clientType": "silver", } ) - JustBeforeEach(func() { - err := AddMetadataToAccount( + JustBeforeEach(func(specContext SpecContext) { + _, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.AddMetadataToAccount( ctx, - testServer.GetValue(), operations.V2AddMetadataToAccountRequest{ RequestBody: newMetadata, Address: "foo", @@ -96,10 +95,9 @@ var _ = Context("Ledger accounts metadata API tests", func() { ) Expect(err).ToNot(HaveOccurred()) }) - It("should update the metadata", func() { - response, err := GetAccount( + It("should update the metadata", func(specContext SpecContext) { + response, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.GetAccount( ctx, - testServer.GetValue(), operations.V2GetAccountRequest{ Address: "foo", Ledger: "default", @@ -107,7 +105,7 @@ var _ = Context("Ledger accounts metadata API tests", func() { ) Expect(err).ToNot(HaveOccurred()) - Expect(*response).Should(Equal(components.V2Account{ + Expect(response.V2AccountResponse.Data).Should(Equal(components.V2Account{ Address: "foo", Metadata: newMetadata, })) @@ -120,10 +118,9 @@ var _ = Context("Ledger accounts metadata API tests", func() { BeforeEach(func() { metadata = nil }) - It("should be OK", func() { - response, err := GetAccount( + It("should be OK", func(specContext SpecContext) { + response, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.GetAccount( ctx, - testServer.GetValue(), operations.V2GetAccountRequest{ Address: "foo", Ledger: "default", @@ -131,19 +128,18 @@ var _ = Context("Ledger accounts metadata API tests", func() { ) Expect(err).ToNot(HaveOccurred()) - Expect(*response).Should(Equal(components.V2Account{ + Expect(response.V2AccountResponse.Data).Should(Equal(components.V2Account{ Address: "foo", Metadata: map[string]string{}, })) }) Context("then adding with empty metadata", func() { - It("should be OK", func() { + It("should be OK", func(specContext SpecContext) { // The first call created the row in the database, // the second call should not change the metadata, and checks than updates works. - err := AddMetadataToAccount( + _, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.AddMetadataToAccount( ctx, - testServer.GetValue(), operations.V2AddMetadataToAccountRequest{ RequestBody: metadata, Address: "foo", @@ -152,9 +148,8 @@ var _ = Context("Ledger accounts metadata API tests", func() { ) Expect(err).ToNot(HaveOccurred()) - response, err := GetAccount( + response, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.GetAccount( ctx, - testServer.GetValue(), operations.V2GetAccountRequest{ Address: "foo", Ledger: "default", @@ -162,7 +157,7 @@ var _ = Context("Ledger accounts metadata API tests", func() { ) Expect(err).ToNot(HaveOccurred()) - Expect(*response).Should(Equal(components.V2Account{ + Expect(response.V2AccountResponse.Data).Should(Equal(components.V2Account{ Address: "foo", Metadata: map[string]string{}, })) diff --git a/test/e2e/api_balances_aggregated_test.go b/test/e2e/api_balances_aggregated_test.go index 3099e69cbb..23a4de019c 100644 --- a/test/e2e/api_balances_aggregated_test.go +++ b/test/e2e/api_balances_aggregated_test.go @@ -5,12 +5,13 @@ package test_suite import ( "github.com/formancehq/go-libs/v2/logging" "github.com/formancehq/go-libs/v2/pointer" - "github.com/formancehq/go-libs/v2/testing/deferred" + . "github.com/formancehq/go-libs/v2/testing/deferred/ginkgo" "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" "github.com/formancehq/go-libs/v2/testing/testservice" "github.com/formancehq/ledger/pkg/client/models/components" "github.com/formancehq/ledger/pkg/client/models/operations" . "github.com/formancehq/ledger/pkg/testserver" + "github.com/formancehq/ledger/pkg/testserver/ginkgo" "math/big" "time" @@ -24,8 +25,8 @@ var _ = Context("Ledger engine tests", func() { ctx = logging.TestingContext() ) - testServer := DeferTestServer( - deferred.DeferMap(db, (*pgtesting.Database).ConnectionOptions), + testServer := ginkgo.DeferTestServer( + DeferMap(db, (*pgtesting.Database).ConnectionOptions), testservice.WithInstruments( testservice.DebugInstrumentation(debug), testservice.OutputInstrumentation(GinkgoWriter), @@ -35,13 +36,13 @@ var _ = Context("Ledger engine tests", func() { now := time.Now().UTC().Round(time.Second) When("creating two transactions on a ledger with custom metadata", func() { var firstTransactionsInsertedAt time.Time - BeforeEach(func() { - err := CreateLedger(ctx, testServer.GetValue(), operations.V2CreateLedgerRequest{ + BeforeEach(func(specContext SpecContext) { + _, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.CreateLedger(ctx, operations.V2CreateLedgerRequest{ Ledger: "default", }) Expect(err).To(BeNil()) - ret, err := CreateBulk(ctx, testServer.GetValue(), operations.V2CreateBulkRequest{ + ret, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.CreateBulk(ctx, operations.V2CreateBulkRequest{ RequestBody: []components.V2BulkElement{ components.CreateV2BulkElementCreateTransaction(components.V2BulkElementCreateTransaction{ Data: &components.V2PostTransaction{ @@ -102,9 +103,9 @@ var _ = Context("Ledger engine tests", func() { }) Expect(err).To(Succeed()) - firstTransactionsInsertedAt = *ret[2].V2BulkElementResultCreateTransaction.Data.InsertedAt + firstTransactionsInsertedAt = *ret.V2BulkResponse.Data[2].V2BulkElementResultCreateTransaction.Data.InsertedAt - _, err = CreateBulk(ctx, testServer.GetValue(), operations.V2CreateBulkRequest{ + _, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.CreateBulk(ctx, operations.V2CreateBulkRequest{ RequestBody: []components.V2BulkElement{ components.CreateV2BulkElementCreateTransaction(components.V2BulkElementCreateTransaction{ Data: &components.V2PostTransaction{ @@ -123,10 +124,9 @@ var _ = Context("Ledger engine tests", func() { }) Expect(err).To(Succeed()) }) - It("should be ok when aggregating using the metadata", func() { - response, err := GetBalancesAggregated( + It("should be ok when aggregating using the metadata", func(specContext SpecContext) { + response, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.GetBalancesAggregated( ctx, - testServer.GetValue(), operations.V2GetBalancesAggregatedRequest{ RequestBody: map[string]any{ "$match": map[string]any{ @@ -138,13 +138,12 @@ var _ = Context("Ledger engine tests", func() { ) Expect(err).ToNot(HaveOccurred()) - Expect(response).To(HaveLen(1)) - Expect(response["USD/2"]).To(Equal(big.NewInt(400))) + Expect(response.V2AggregateBalancesResponse.Data).To(HaveLen(1)) + Expect(response.V2AggregateBalancesResponse.Data["USD/2"]).To(Equal(big.NewInt(400))) }) - It("should be ok when aggregating using pit on effective date", func() { - response, err := GetBalancesAggregated( + It("should be ok when aggregating using pit on effective date", func(specContext SpecContext) { + response, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.GetBalancesAggregated( ctx, - testServer.GetValue(), operations.V2GetBalancesAggregatedRequest{ Ledger: "default", Pit: pointer.For(now.Add(-time.Minute)), @@ -157,13 +156,12 @@ var _ = Context("Ledger engine tests", func() { ) Expect(err).ToNot(HaveOccurred()) - Expect(response).To(HaveLen(1)) - Expect(response["USD/2"]).To(Equal(big.NewInt(100))) + Expect(response.V2AggregateBalancesResponse.Data).To(HaveLen(1)) + Expect(response.V2AggregateBalancesResponse.Data["USD/2"]).To(Equal(big.NewInt(100))) }) - It("should be ok when aggregating using pit on insertion date", func() { - response, err := GetBalancesAggregated( + It("should be ok when aggregating using pit on insertion date", func(specContext SpecContext) { + response, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.GetBalancesAggregated( ctx, - testServer.GetValue(), operations.V2GetBalancesAggregatedRequest{ Ledger: "default", Pit: pointer.For(firstTransactionsInsertedAt), @@ -177,8 +175,8 @@ var _ = Context("Ledger engine tests", func() { ) Expect(err).ToNot(HaveOccurred()) - Expect(response).To(HaveLen(1)) - Expect(response["USD/2"]).To(Equal(big.NewInt(200))) + Expect(response.V2AggregateBalancesResponse.Data).To(HaveLen(1)) + Expect(response.V2AggregateBalancesResponse.Data["USD/2"]).To(Equal(big.NewInt(200))) }) }) }) diff --git a/test/e2e/api_bulk_test.go b/test/e2e/api_bulk_test.go index 15068cc6be..563686e590 100644 --- a/test/e2e/api_bulk_test.go +++ b/test/e2e/api_bulk_test.go @@ -6,13 +6,15 @@ import ( "bytes" "encoding/json" "github.com/formancehq/go-libs/v2/pointer" - "github.com/formancehq/go-libs/v2/testing/deferred" + "github.com/formancehq/go-libs/v2/testing/deferred/ginkgo" + . "github.com/formancehq/go-libs/v2/testing/deferred/ginkgo" "github.com/formancehq/go-libs/v2/testing/platform/natstesting" "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" "github.com/formancehq/go-libs/v2/testing/testservice" ledger "github.com/formancehq/ledger/internal" "github.com/formancehq/ledger/internal/bus" ledgerevents "github.com/formancehq/ledger/pkg/events" + . "github.com/formancehq/ledger/pkg/testserver/ginkgo" "github.com/nats-io/nats.go" "math/big" "net/http" @@ -35,13 +37,13 @@ var _ = Context("Ledger engine tests", func() { db = UseTemplatedDatabase() ctx = logging.TestingContext() events chan *nats.Msg - bulkResponse []components.V2BulkElementResult + bulkResponse *operations.V2CreateBulkResponse bulkMaxSize = 100 - natsURL = deferred.DeferMap(natsServer, (*natstesting.NatsServer).ClientURL) + natsURL = ginkgo.DeferMap(natsServer, (*natstesting.NatsServer).ClientURL) ) testServer := DeferTestServer( - deferred.DeferMap(db, (*pgtesting.Database).ConnectionOptions), + ginkgo.DeferMap(db, (*pgtesting.Database).ConnectionOptions), testservice.WithInstruments( testservice.NatsInstrumentation(natsURL), testservice.DebugInstrumentation(debug), @@ -50,12 +52,12 @@ var _ = Context("Ledger engine tests", func() { testservice.WithLogger(GinkgoT()), ) - BeforeEach(func() { - err := CreateLedger(ctx, testServer.GetValue(), operations.V2CreateLedgerRequest{ + BeforeEach(func(specContext SpecContext) { + _, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.CreateLedger(ctx, operations.V2CreateLedgerRequest{ Ledger: "default", }) Expect(err).To(BeNil()) - _, events = Subscribe(GinkgoT(), testServer.GetValue(), natsURL) + _, events = Subscribe(specContext, testServer, natsURL) }) When("creating a bulk on a ledger", func() { var ( @@ -104,29 +106,29 @@ var _ = Context("Ledger engine tests", func() { }), } }) - JustBeforeEach(func() { - bulkResponse, err = CreateBulk(ctx, testServer.GetValue(), operations.V2CreateBulkRequest{ + JustBeforeEach(func(specContext SpecContext) { + bulkResponse, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.CreateBulk(ctx, operations.V2CreateBulkRequest{ Atomic: pointer.For(atomic), Parallel: pointer.For(parallel), RequestBody: items, Ledger: "default", }) }) - shouldBeOk := func() { + shouldBeOk := func(specContext SpecContext) { Expect(err).To(Succeed()) - tx, err := GetTransaction(ctx, testServer.GetValue(), operations.V2GetTransactionRequest{ + tx, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.GetTransaction(ctx, operations.V2GetTransactionRequest{ ID: big.NewInt(1), Ledger: "default", }) Expect(err).To(Succeed()) - reversedTx, err := GetTransaction(ctx, testServer.GetValue(), operations.V2GetTransactionRequest{ + reversedTx, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.GetTransaction(ctx, operations.V2GetTransactionRequest{ ID: big.NewInt(2), Ledger: "default", }) Expect(err).To(Succeed()) - Expect(*tx).To(Equal(components.V2Transaction{ + Expect(tx.V2GetTransactionResponse.Data).To(Equal(components.V2Transaction{ ID: big.NewInt(1), Metadata: metadata.Metadata{ "role": "admin", @@ -138,9 +140,9 @@ var _ = Context("Ledger engine tests", func() { Source: "world", }}, Reverted: true, - RevertedAt: &reversedTx.Timestamp, + RevertedAt: &reversedTx.V2GetTransactionResponse.Data.Timestamp, Timestamp: now, - InsertedAt: tx.InsertedAt, + InsertedAt: tx.V2GetTransactionResponse.Data.InsertedAt, })) By("It should send events", func() { Eventually(events).Should(Receive(Event(ledgerevents.EventTypeCommittedTransactions))) @@ -236,7 +238,7 @@ var _ = Context("Ledger engine tests", func() { }), } }) - JustBeforeEach(func() { + JustBeforeEach(func(specContext SpecContext) { stream := bytes.NewBuffer(nil) for _, item := range items { data, err := json.Marshal(item) @@ -245,7 +247,10 @@ var _ = Context("Ledger engine tests", func() { } stream.Write([]byte("\n")) - req, err := http.NewRequest(http.MethodPost, testservice.GetServerURL(testServer.GetValue()).String()+"/v2/default/_bulk", stream) + testServer, err := testServer.Wait(specContext) + Expect(err).To(BeNil()) + + req, err := http.NewRequest(http.MethodPost, testservice.GetServerURL(testServer).String()+"/v2/default/_bulk", stream) req.Header.Set("Content-Type", "application/vnd.formance.ledger.api.v2.bulk+json-stream") Expect(err).To(Succeed()) @@ -253,14 +258,14 @@ var _ = Context("Ledger engine tests", func() { Expect(err).To(Succeed()) Expect(rsp.StatusCode).To(Equal(http.StatusOK)) }) - It("should be ok", func() { + It("should be ok", func(specContext SpecContext) { Expect(err).To(Succeed()) - txs, err := ListTransactions(ctx, testServer.GetValue(), operations.V2ListTransactionsRequest{ + txs, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.ListTransactions(ctx, operations.V2ListTransactionsRequest{ Ledger: "default", }) Expect(err).To(Succeed()) - Expect(txs.Data).To(HaveLen(2)) + Expect(txs.V2TransactionsCursorResponse.Cursor.Data).To(HaveLen(2)) }) }) When("creating a bulk with an error on a ledger", func() { @@ -269,8 +274,8 @@ var _ = Context("Ledger engine tests", func() { err error atomic bool ) - JustBeforeEach(func() { - bulkResponse, err = CreateBulk(ctx, testServer.GetValue(), operations.V2CreateBulkRequest{ + JustBeforeEach(func(specContext SpecContext) { + bulkResponse, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.CreateBulk(ctx, operations.V2CreateBulkRequest{ Atomic: pointer.For(atomic), RequestBody: []components.V2BulkElement{ components.CreateV2BulkElementCreateTransaction(components.V2BulkElementCreateTransaction{ @@ -305,24 +310,24 @@ var _ = Context("Ledger engine tests", func() { shouldRespondWithAnError := func() { GinkgoHelper() - Expect(bulkResponse[1].Type).To(Equal(components.V2BulkElementResultType("ERROR"))) - Expect(bulkResponse[1].V2BulkElementResultError.ErrorCode).To(Equal("INSUFFICIENT_FUND")) + Expect(bulkResponse.V2BulkResponse.Data[1].Type).To(Equal(components.V2BulkElementResultType("ERROR"))) + Expect(bulkResponse.V2BulkResponse.Data[1].V2BulkElementResultError.ErrorCode).To(Equal("INSUFFICIENT_FUND")) } - It("should respond with an error", func() { + It("should respond with an error", func(specContext SpecContext) { shouldRespondWithAnError() By("should have created the first item", func() { - txs, err := ListTransactions(ctx, testServer.GetValue(), operations.V2ListTransactionsRequest{ + txs, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.ListTransactions(ctx, operations.V2ListTransactionsRequest{ Ledger: "default", }) Expect(err).To(Succeed()) - Expect(txs.Data).To(HaveLen(1)) + Expect(txs.V2TransactionsCursorResponse.Cursor.Data).To(HaveLen(1)) }) By("Should have sent one event", func() { Eventually(events).Should(Receive(Event(ledgerevents.EventTypeCommittedTransactions, WithPayload(bus.CommittedTransactions{ Ledger: "default", - Transactions: []ledger.Transaction{ConvertSDKTxToCoreTX(&bulkResponse[0].V2BulkElementResultCreateTransaction.Data)}, + Transactions: []ledger.Transaction{ConvertSDKTxToCoreTX(&bulkResponse.V2BulkResponse.Data[0].V2BulkElementResultCreateTransaction.Data)}, AccountMetadata: ledger.AccountMetadata{}, })))) Eventually(events).ShouldNot(Receive()) @@ -332,14 +337,14 @@ var _ = Context("Ledger engine tests", func() { BeforeEach(func() { atomic = true }) - It("should not commit anything", func() { + It("should not commit anything", func(specContext SpecContext) { shouldRespondWithAnError() - txs, err := ListTransactions(ctx, testServer.GetValue(), operations.V2ListTransactionsRequest{ + txs, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.ListTransactions(ctx, operations.V2ListTransactionsRequest{ Ledger: "default", }) Expect(err).To(Succeed()) - Expect(txs.Data).To(HaveLen(0)) + Expect(txs.V2TransactionsCursorResponse.Cursor.Data).To(HaveLen(0)) By("Should not have sent any event", func() { Eventually(events).ShouldNot(Receive()) diff --git a/test/e2e/api_ledgers_create_test.go b/test/e2e/api_ledgers_create_test.go index 3282465d60..0736f8b08d 100644 --- a/test/e2e/api_ledgers_create_test.go +++ b/test/e2e/api_ledgers_create_test.go @@ -6,7 +6,7 @@ import ( "github.com/formancehq/go-libs/v2/logging" "github.com/formancehq/go-libs/v2/pointer" . "github.com/formancehq/go-libs/v2/testing/api" - "github.com/formancehq/go-libs/v2/testing/deferred" + . "github.com/formancehq/go-libs/v2/testing/deferred/ginkgo" "github.com/formancehq/go-libs/v2/testing/platform/natstesting" "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" "github.com/formancehq/go-libs/v2/testing/testservice" @@ -14,6 +14,7 @@ import ( "github.com/formancehq/ledger/pkg/client/models/operations" "github.com/formancehq/ledger/pkg/features" . "github.com/formancehq/ledger/pkg/testserver" + "github.com/formancehq/ledger/pkg/testserver/ginkgo" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "strings" @@ -23,11 +24,11 @@ var _ = Context("Ledger engine tests", func() { var ( db = UseTemplatedDatabase() ctx = logging.TestingContext() - natsURL = deferred.DeferMap(natsServer, (*natstesting.NatsServer).ClientURL) + natsURL = DeferMap(natsServer, (*natstesting.NatsServer).ClientURL) ) - testServer := DeferTestServer( - deferred.DeferMap(db, (*pgtesting.Database).ConnectionOptions), + testServer := ginkgo.DeferTestServer( + DeferMap(db, (*pgtesting.Database).ConnectionOptions), testservice.WithInstruments( testservice.NatsInstrumentation(natsURL), testservice.DebugInstrumentation(debug), @@ -48,8 +49,8 @@ var _ = Context("Ledger engine tests", func() { V2CreateLedgerRequest: components.V2CreateLedgerRequest{}, } }) - JustBeforeEach(func() { - err = CreateLedger(ctx, testServer.GetValue(), createLedgerRequest) + JustBeforeEach(func(specContext SpecContext) { + _, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.CreateLedger(ctx, createLedgerRequest) }) It("should be ok", func() { Expect(err).To(BeNil()) @@ -82,8 +83,8 @@ var _ = Context("Ledger engine tests", func() { }) }) Context("trying to create another ledger with the same name", func() { - JustBeforeEach(func() { - err := CreateLedger(ctx, testServer.GetValue(), operations.V2CreateLedgerRequest{ + JustBeforeEach(func(specContext SpecContext) { + _, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.CreateLedger(ctx, operations.V2CreateLedgerRequest{ Ledger: createLedgerRequest.Ledger, }) Expect(err).NotTo(BeNil()) @@ -105,12 +106,12 @@ var _ = Context("Ledger engine tests", func() { "foo": "bar", } }) - It("Should be ok", func() { - ledger, err := GetLedger(ctx, testServer.GetValue(), operations.V2GetLedgerRequest{ + It("Should be ok", func(specContext SpecContext) { + ledger, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.GetLedger(ctx, operations.V2GetLedgerRequest{ Ledger: createLedgerRequest.Ledger, }) Expect(err).To(BeNil()) - Expect(ledger.Metadata).To(Equal(createLedgerRequest.V2CreateLedgerRequest.Metadata)) + Expect(ledger.V2GetLedgerResponse.Data.Metadata).To(Equal(createLedgerRequest.V2CreateLedgerRequest.Metadata)) }) }) Context("with invalid ledger name", func() { diff --git a/test/e2e/api_ledgers_import_test.go b/test/e2e/api_ledgers_import_test.go index 133fca1278..b019082cab 100644 --- a/test/e2e/api_ledgers_import_test.go +++ b/test/e2e/api_ledgers_import_test.go @@ -7,17 +7,17 @@ import ( "github.com/formancehq/go-libs/v2/logging" "github.com/formancehq/go-libs/v2/pointer" . "github.com/formancehq/go-libs/v2/testing/api" - "github.com/formancehq/go-libs/v2/testing/deferred" + . "github.com/formancehq/go-libs/v2/testing/deferred/ginkgo" "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" "github.com/formancehq/go-libs/v2/testing/testservice" "github.com/formancehq/ledger/pkg/client/models/components" "github.com/formancehq/ledger/pkg/client/models/operations" "github.com/formancehq/ledger/pkg/features" . "github.com/formancehq/ledger/pkg/testserver" + . "github.com/formancehq/ledger/pkg/testserver/ginkgo" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "github.com/uptrace/bun" - "io" "math/big" ) @@ -25,7 +25,7 @@ var _ = Context("Ledger engine tests", func() { var ( db = UseTemplatedDatabase() ctx = logging.TestingContext() - connectionOptions = deferred.DeferMap(db, (*pgtesting.Database).ConnectionOptions) + connectionOptions = DeferMap(db, (*pgtesting.Database).ConnectionOptions) ) testServer := DeferTestServer( @@ -51,37 +51,39 @@ var _ = Context("Ledger engine tests", func() { }, } }) - JustBeforeEach(func() { - err = CreateLedger(ctx, testServer.GetValue(), createLedgerRequest) + JustBeforeEach(func(specContext SpecContext) { + _, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.CreateLedger(ctx, createLedgerRequest) }) When("importing data in two steps", func() { - It("should be ok", func() { + It("should be ok", func(specContext SpecContext) { firstBatch := `{"type":"NEW_TRANSACTION","data":{"transaction":{"postings":[{"source":"world","destination":"payments:1234","amount":10000,"asset":"EUR/2"}],"metadata":{},"timestamp":"2025-02-17T12:07:41.522336Z","id":0,"reverted":false},"accountMetadata":{}},"date":"2025-02-17T12:07:41.534898Z","idempotencyKey":"","id":0,"hash":"g489GFReBqquboEjkB95X3OU6mheMzgiu63PdSTfMuM="} {"type":"NEW_TRANSACTION","data":{"transaction":{"postings":[{"source":"payments:1234","destination":"platform","amount":1500,"asset":"EUR/2"},{"source":"payments:1234","destination":"merchants:777","amount":8500,"asset":"EUR/2"}],"metadata":{},"timestamp":"2025-02-17T12:07:55.145802Z","id":1,"reverted":false},"accountMetadata":{}},"date":"2025-02-17T12:07:55.170731Z","idempotencyKey":"","id":1,"hash":"T+2SGiCeC8tagt1tf5E/L7r98wB8tm6EbNd+OJ7ZvCI="}` - Expect(Import(ctx, testServer.GetValue(), operations.V2ImportLogsRequest{ + _, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.ImportLogs(ctx, operations.V2ImportLogsRequest{ Ledger: createLedgerRequest.Ledger, V2ImportLogsRequest: []byte(firstBatch), - })).To(BeNil()) + }) + Expect(err).To(BeNil()) secondBatch := `{"type":"NEW_TRANSACTION","data":{"transaction":{"postings":[{"source":"merchants:777","destination":"payouts:987","amount":8500,"asset":"EUR/2"}],"metadata":{},"timestamp":"2025-02-17T12:08:24.955784Z","id":2,"reverted":false},"accountMetadata":{}},"date":"2025-02-17T12:08:24.985834Z","idempotencyKey":"","id":2,"hash":"WgOIXsh8x0pGSi//jHjQ78RF9YnFRslsbp2aOHiG43U="} {"type":"NEW_TRANSACTION","data":{"transaction":{"postings":[{"source":"platform","destination":"refunds:4567","amount":5000,"asset":"EUR/2"}],"metadata":{},"timestamp":"2025-02-17T12:08:39.301709Z","id":3,"reverted":false},"accountMetadata":{}},"date":"2025-02-17T12:08:39.330919Z","idempotencyKey":"","id":3,"hash":"JblhzL91s+DTcd53YTV2laC4QBRe5oDDoz9CzsX5Pro="} {"type":"NEW_TRANSACTION","data":{"transaction":{"postings":[{"source":"refunds:4567","destination":"world","amount":5000,"asset":"EUR/2"}],"metadata":{},"timestamp":"2025-02-17T12:11:02.413499Z","id":4,"reverted":false},"accountMetadata":{}},"date":"2025-02-17T12:11:02.434078Z","idempotencyKey":"","id":4,"hash":"Y8TBz5GhxTWW9D/wRXHPcIlrYFPQjroiIBWX1q6SJJo="}` - Expect(Import(ctx, testServer.GetValue(), operations.V2ImportLogsRequest{ + _, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.ImportLogs(ctx, operations.V2ImportLogsRequest{ Ledger: createLedgerRequest.Ledger, V2ImportLogsRequest: []byte(secondBatch), - })).To(BeNil()) + }) + Expect(err).To(BeNil()) - logsFromOriginalLedger, err := ListLogs(ctx, testServer.GetValue(), operations.V2ListLogsRequest{ + logsFromOriginalLedger, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.ListLogs(ctx, operations.V2ListLogsRequest{ Ledger: createLedgerRequest.Ledger, }) Expect(err).To(Succeed()) - Expect(logsFromOriginalLedger.Data).To(HaveLen(5)) + Expect(logsFromOriginalLedger.V2LogsCursorResponse.Cursor.Data).To(HaveLen(5)) }) }) When("importing data from 2.1", func() { - importLogs := func() error { + importLogs := func(specContext SpecContext) error { GinkgoHelper() logs := `{"type":"NEW_TRANSACTION","data":{"transaction":{"postings":[{"source":"world","destination":"payments:1234","amount":10000,"asset":"EUR/2"}],"metadata":{},"timestamp":"2025-02-17T12:07:41.522336Z","id":0,"reverted":false},"accountMetadata":{}},"date":"2025-02-17T12:07:41.534898Z","idempotencyKey":"","id":0,"hash":"g489GFReBqquboEjkB95X3OU6mheMzgiu63PdSTfMuM="} @@ -90,57 +92,58 @@ var _ = Context("Ledger engine tests", func() { {"type":"NEW_TRANSACTION","data":{"transaction":{"postings":[{"source":"platform","destination":"refunds:4567","amount":5000,"asset":"EUR/2"}],"metadata":{},"timestamp":"2025-02-17T12:08:39.301709Z","id":3,"reverted":false},"accountMetadata":{}},"date":"2025-02-17T12:08:39.330919Z","idempotencyKey":"","id":3,"hash":"JblhzL91s+DTcd53YTV2laC4QBRe5oDDoz9CzsX5Pro="} {"type":"NEW_TRANSACTION","data":{"transaction":{"postings":[{"source":"refunds:4567","destination":"world","amount":5000,"asset":"EUR/2"}],"metadata":{},"timestamp":"2025-02-17T12:11:02.413499Z","id":4,"reverted":false},"accountMetadata":{}},"date":"2025-02-17T12:11:02.434078Z","idempotencyKey":"","id":4,"hash":"Y8TBz5GhxTWW9D/wRXHPcIlrYFPQjroiIBWX1q6SJJo="}` - return Import(ctx, testServer.GetValue(), operations.V2ImportLogsRequest{ + _, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.ImportLogs(ctx, operations.V2ImportLogsRequest{ Ledger: createLedgerRequest.Ledger, V2ImportLogsRequest: []byte(logs), }) + return err } - It("should be ok", func() { - Expect(importLogs()).To(Succeed()) + It("should be ok", func(specContext SpecContext) { + Expect(importLogs(specContext)).To(Succeed()) - logsFromOriginalLedger, err := ListLogs(ctx, testServer.GetValue(), operations.V2ListLogsRequest{ + logsFromOriginalLedger, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.ListLogs(ctx, operations.V2ListLogsRequest{ Ledger: createLedgerRequest.Ledger, }) Expect(err).To(Succeed()) - logsFromNewLedger, err := ListLogs(ctx, testServer.GetValue(), operations.V2ListLogsRequest{ + logsFromNewLedger, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.ListLogs(ctx, operations.V2ListLogsRequest{ Ledger: createLedgerRequest.Ledger, }) Expect(err).To(Succeed()) - Expect(logsFromOriginalLedger.Data).To(Equal(logsFromNewLedger.Data)) + Expect(logsFromOriginalLedger.V2LogsCursorResponse.Cursor.Data).To(Equal(logsFromNewLedger.V2LogsCursorResponse.Cursor.Data)) - transactionsFromOriginalLedger, err := ListTransactions(ctx, testServer.GetValue(), operations.V2ListTransactionsRequest{ + transactionsFromOriginalLedger, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.ListTransactions(ctx, operations.V2ListTransactionsRequest{ Ledger: createLedgerRequest.Ledger, }) Expect(err).To(Succeed()) - transactionsFromNewLedger, err := ListTransactions(ctx, testServer.GetValue(), operations.V2ListTransactionsRequest{ + transactionsFromNewLedger, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.ListTransactions(ctx, operations.V2ListTransactionsRequest{ Ledger: createLedgerRequest.Ledger, }) Expect(err).To(Succeed()) - Expect(transactionsFromOriginalLedger.Data).To(Equal(transactionsFromNewLedger.Data)) + Expect(transactionsFromOriginalLedger.V2TransactionsCursorResponse.Cursor.Data).To(Equal(transactionsFromNewLedger.V2TransactionsCursorResponse.Cursor.Data)) - accountsFromOriginalLedger, err := ListAccounts(ctx, testServer.GetValue(), operations.V2ListAccountsRequest{ + accountsFromOriginalLedger, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.ListAccounts(ctx, operations.V2ListAccountsRequest{ Ledger: createLedgerRequest.Ledger, }) Expect(err).To(Succeed()) - accountsFromNewLedger, err := ListAccounts(ctx, testServer.GetValue(), operations.V2ListAccountsRequest{ + accountsFromNewLedger, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.ListAccounts(ctx, operations.V2ListAccountsRequest{ Ledger: createLedgerRequest.Ledger, }) Expect(err).To(Succeed()) - Expect(accountsFromOriginalLedger.Data).To(Equal(accountsFromNewLedger.Data)) + Expect(accountsFromOriginalLedger.V2AccountsCursorResponse.Cursor.Data).To(Equal(accountsFromNewLedger.V2AccountsCursorResponse.Cursor.Data)) }) }) Context("with a set of all possible actions", func() { - JustBeforeEach(func() { + JustBeforeEach(func(specContext SpecContext) { Expect(err).To(BeNil()) - firstTX, err := CreateTransaction(ctx, testServer.GetValue(), operations.V2CreateTransactionRequest{ + firstTX, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.CreateTransaction(ctx, operations.V2CreateTransactionRequest{ Ledger: createLedgerRequest.Ledger, V2PostTransaction: components.V2PostTransaction{ Script: &components.V2PostTransactionScript{ @@ -156,7 +159,7 @@ var _ = Context("Ledger engine tests", func() { Expect(err).To(BeNil()) // add a tx with a dry run to trigger a hole in ids - _, err = CreateTransaction(ctx, testServer.GetValue(), operations.V2CreateTransactionRequest{ + _, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.CreateTransaction(ctx, operations.V2CreateTransactionRequest{ Ledger: createLedgerRequest.Ledger, DryRun: pointer.For(true), V2PostTransaction: components.V2PostTransaction{ @@ -172,7 +175,7 @@ var _ = Context("Ledger engine tests", func() { }) Expect(err).To(BeNil()) - thirdTx, err := CreateTransaction(ctx, testServer.GetValue(), operations.V2CreateTransactionRequest{ + thirdTx, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.CreateTransaction(ctx, operations.V2CreateTransactionRequest{ Ledger: createLedgerRequest.Ledger, V2PostTransaction: components.V2PostTransaction{ Script: &components.V2PostTransactionScript{ @@ -187,55 +190,60 @@ var _ = Context("Ledger engine tests", func() { }) Expect(err).To(BeNil()) - Expect(AddMetadataToTransaction(ctx, testServer.GetValue(), operations.V2AddMetadataOnTransactionRequest{ + _, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.AddMetadataOnTransaction(ctx, operations.V2AddMetadataOnTransactionRequest{ Ledger: createLedgerRequest.Ledger, - ID: firstTX.ID, + ID: firstTX.V2CreateTransactionResponse.Data.ID, RequestBody: map[string]string{ "foo": "bar", }, - })).To(BeNil()) + }) + Expect(err).To(BeNil()) - Expect(AddMetadataToTransaction(ctx, testServer.GetValue(), operations.V2AddMetadataOnTransactionRequest{ + _, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.AddMetadataOnTransaction(ctx, operations.V2AddMetadataOnTransactionRequest{ Ledger: createLedgerRequest.Ledger, - ID: thirdTx.ID, + ID: thirdTx.V2CreateTransactionResponse.Data.ID, RequestBody: map[string]string{ "foo": "baz", }, - })).To(BeNil()) + }) + Expect(err).To(BeNil()) - Expect(AddMetadataToAccount(ctx, testServer.GetValue(), operations.V2AddMetadataToAccountRequest{ + _, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.AddMetadataToAccount(ctx, operations.V2AddMetadataToAccountRequest{ Ledger: createLedgerRequest.Ledger, Address: "bank", RequestBody: map[string]string{ "foo": "bar", }, - })).To(BeNil()) + }) + Expect(err).To(BeNil()) - Expect(DeleteTransactionMetadata(ctx, testServer.GetValue(), operations.V2DeleteTransactionMetadataRequest{ + _, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.DeleteTransactionMetadata(ctx, operations.V2DeleteTransactionMetadataRequest{ Ledger: createLedgerRequest.Ledger, - ID: firstTX.ID, + ID: firstTX.V2CreateTransactionResponse.Data.ID, Key: "foo", - })).To(BeNil()) + }) + Expect(err).To(BeNil()) - Expect(DeleteAccountMetadata(ctx, testServer.GetValue(), operations.V2DeleteAccountMetadataRequest{ + _, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.DeleteAccountMetadata(ctx, operations.V2DeleteAccountMetadataRequest{ Ledger: createLedgerRequest.Ledger, Address: "world", Key: "foo", - })).To(BeNil()) + }) + Expect(err).To(BeNil()) - _, err = RevertTransaction(ctx, testServer.GetValue(), operations.V2RevertTransactionRequest{ + _, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.RevertTransaction(ctx, operations.V2RevertTransactionRequest{ Ledger: createLedgerRequest.Ledger, - ID: firstTX.ID, + ID: firstTX.V2CreateTransactionResponse.Data.ID, }) Expect(err).To(BeNil()) }) When("exporting the logs", func() { var ( - reader io.Reader - err error + response *operations.V2ExportLogsResponse + err error ) - JustBeforeEach(func() { - reader, err = Export(ctx, testServer.GetValue(), operations.V2ExportLogsRequest{ + JustBeforeEach(func(specContext SpecContext) { + response, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.ExportLogs(ctx, operations.V2ExportLogsRequest{ Ledger: createLedgerRequest.Ledger, }) Expect(err).To(BeNil()) @@ -243,9 +251,9 @@ var _ = Context("Ledger engine tests", func() { It("should be ok", func() {}) When("then create a new ledger", func() { var ledgerCopyName string - JustBeforeEach(func() { + JustBeforeEach(func(specContext SpecContext) { ledgerCopyName = createLedgerRequest.Ledger + "-copy" - err := CreateLedger(ctx, testServer.GetValue(), operations.V2CreateLedgerRequest{ + _, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.CreateLedger(ctx, operations.V2CreateLedgerRequest{ Ledger: ledgerCopyName, V2CreateLedgerRequest: components.V2CreateLedgerRequest{ Features: features.MinimalFeatureSet, @@ -254,59 +262,60 @@ var _ = Context("Ledger engine tests", func() { Expect(err).To(BeNil()) }) - importLogs := func() error { + importLogs := func(specContext SpecContext) error { GinkgoHelper() - return Import(ctx, testServer.GetValue(), operations.V2ImportLogsRequest{ + _, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.ImportLogs(ctx, operations.V2ImportLogsRequest{ Ledger: ledgerCopyName, - V2ImportLogsRequest: reader, + V2ImportLogsRequest: response.HTTPMeta.Response.Body, }) + return err } When("importing data", func() { - It("should be ok", func() { - Expect(importLogs()).To(Succeed()) + It("should be ok", func(specContext SpecContext) { + Expect(importLogs(specContext)).To(Succeed()) - logsFromOriginalLedger, err := ListLogs(ctx, testServer.GetValue(), operations.V2ListLogsRequest{ + logsFromOriginalLedger, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.ListLogs(ctx, operations.V2ListLogsRequest{ Ledger: createLedgerRequest.Ledger, }) Expect(err).To(Succeed()) - logsFromNewLedger, err := ListLogs(ctx, testServer.GetValue(), operations.V2ListLogsRequest{ + logsFromNewLedger, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.ListLogs(ctx, operations.V2ListLogsRequest{ Ledger: ledgerCopyName, }) Expect(err).To(Succeed()) - Expect(logsFromOriginalLedger.Data).To(Equal(logsFromNewLedger.Data)) + Expect(logsFromOriginalLedger.V2LogsCursorResponse.Cursor.Data).To(Equal(logsFromNewLedger.V2LogsCursorResponse.Cursor.Data)) - transactionsFromOriginalLedger, err := ListTransactions(ctx, testServer.GetValue(), operations.V2ListTransactionsRequest{ + transactionsFromOriginalLedger, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.ListTransactions(ctx, operations.V2ListTransactionsRequest{ Ledger: createLedgerRequest.Ledger, }) Expect(err).To(Succeed()) - transactionsFromNewLedger, err := ListTransactions(ctx, testServer.GetValue(), operations.V2ListTransactionsRequest{ + transactionsFromNewLedger, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.ListTransactions(ctx, operations.V2ListTransactionsRequest{ Ledger: ledgerCopyName, }) Expect(err).To(Succeed()) - Expect(transactionsFromOriginalLedger.Data).To(Equal(transactionsFromNewLedger.Data)) + Expect(transactionsFromOriginalLedger.V2TransactionsCursorResponse.Cursor.Data).To(Equal(transactionsFromNewLedger.V2TransactionsCursorResponse.Cursor.Data)) - accountsFromOriginalLedger, err := ListAccounts(ctx, testServer.GetValue(), operations.V2ListAccountsRequest{ + accountsFromOriginalLedger, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.ListAccounts(ctx, operations.V2ListAccountsRequest{ Ledger: createLedgerRequest.Ledger, }) Expect(err).To(Succeed()) - accountsFromNewLedger, err := ListAccounts(ctx, testServer.GetValue(), operations.V2ListAccountsRequest{ + accountsFromNewLedger, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.ListAccounts(ctx, operations.V2ListAccountsRequest{ Ledger: ledgerCopyName, }) Expect(err).To(Succeed()) - Expect(accountsFromOriginalLedger.Data).To(Equal(accountsFromNewLedger.Data)) + Expect(accountsFromOriginalLedger.V2AccountsCursorResponse.Cursor.Data).To(Equal(accountsFromNewLedger.V2AccountsCursorResponse.Cursor.Data)) }) }) Context("with state to 'in-use'", func() { - JustBeforeEach(func() { - _, err := CreateTransaction(ctx, testServer.GetValue(), operations.V2CreateTransactionRequest{ + JustBeforeEach(func(specContext SpecContext) { + _, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.CreateTransaction(ctx, operations.V2CreateTransactionRequest{ Ledger: ledgerCopyName, V2PostTransaction: components.V2PostTransaction{ Postings: []components.V2Posting{{ @@ -320,8 +329,8 @@ var _ = Context("Ledger engine tests", func() { Expect(err).To(BeNil()) }) When("importing data", func() { - It("Should fail with IMPORT code", func() { - err := importLogs() + It("Should fail with IMPORT code", func(specContext SpecContext) { + err := importLogs(specContext) Expect(err).To(HaveErrorCode(string(components.V2ErrorsEnumImport))) }) }) @@ -334,11 +343,11 @@ var _ = Context("Ledger engine tests", func() { ) // the import process is relying on the ledger state // it the ledger already has some logs, it is considered as in use and import must fails. - // as the sdk does not allow to control the stream passed to the Import function + // as the sdk does not allow to control the stream passed to the ImportLogs function // we take a lock on the ledgers table to force the process to wait // while we will make a concurrent request - JustBeforeEach(func() { - db = ConnectToDatabase(ctx, GinkgoT(), connectionOptions) + JustBeforeEach(func(specContext SpecContext) { + db = ConnectToDatabase(ctx, connectionOptions) sqlTx, err = db.BeginTx(ctx, &sql.TxOptions{}) Expect(err).To(BeNil()) @@ -353,7 +362,7 @@ var _ = Context("Ledger engine tests", func() { defer GinkgoRecover() // should block - _, err := CreateTransaction(ctx, testServer.GetValue(), operations.V2CreateTransactionRequest{ + _, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.CreateTransaction(ctx, operations.V2CreateTransactionRequest{ Ledger: ledgerCopyName, Force: pointer.For(true), V2PostTransaction: components.V2PostTransaction{ @@ -386,8 +395,8 @@ var _ = Context("Ledger engine tests", func() { go func() { defer GinkgoRecover() - // the call on importLogs() should block too since the logs table is locked - importErrChan <- importLogs() + // the call on ImportLogs() should block too since the logs table is locked + importErrChan <- importLogs(specContext) }() Eventually(func(g Gomega) int { diff --git a/test/e2e/api_ledgers_list_test.go b/test/e2e/api_ledgers_list_test.go index 560c5274f0..f66c402e04 100644 --- a/test/e2e/api_ledgers_list_test.go +++ b/test/e2e/api_ledgers_list_test.go @@ -6,12 +6,13 @@ import ( "fmt" "github.com/formancehq/go-libs/v2/logging" "github.com/formancehq/go-libs/v2/pointer" - "github.com/formancehq/go-libs/v2/testing/deferred" + . "github.com/formancehq/go-libs/v2/testing/deferred/ginkgo" "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" "github.com/formancehq/go-libs/v2/testing/testservice" "github.com/formancehq/ledger/pkg/client/models/components" "github.com/formancehq/ledger/pkg/client/models/operations" . "github.com/formancehq/ledger/pkg/testserver" + "github.com/formancehq/ledger/pkg/testserver/ginkgo" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -22,8 +23,8 @@ var _ = Context("Ledger engine tests", func() { ctx = logging.TestingContext() ) - testServer := DeferTestServer( - deferred.DeferMap(db, (*pgtesting.Database).ConnectionOptions), + testServer := ginkgo.DeferTestServer( + DeferMap(db, (*pgtesting.Database).ConnectionOptions), testservice.WithInstruments( testservice.DebugInstrumentation(debug), testservice.OutputInstrumentation(GinkgoWriter), @@ -34,9 +35,9 @@ var _ = Context("Ledger engine tests", func() { ) When("creating 20 ledger", func() { - BeforeEach(func() { + BeforeEach(func(specContext SpecContext) { for i := range 20 { - err := CreateLedger(ctx, testServer.GetValue(), operations.V2CreateLedgerRequest{ + _, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.CreateLedger(ctx, operations.V2CreateLedgerRequest{ Ledger: fmt.Sprintf("ledger%d", i), V2CreateLedgerRequest: components.V2CreateLedgerRequest{ Bucket: pointer.For(fmt.Sprintf("bucket%d", i%2)), @@ -48,15 +49,15 @@ var _ = Context("Ledger engine tests", func() { Expect(err).To(BeNil()) } }) - It("should be listable without filter", func() { - ledgers, err := ListLedgers(ctx, testServer.GetValue(), operations.V2ListLedgersRequest{ + It("should be listable without filter", func(specContext SpecContext) { + ledgers, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.ListLedgers(ctx, operations.V2ListLedgersRequest{ PageSize: pointer.For(int64(100)), }) Expect(err).To(BeNil()) - Expect(ledgers.Data).To(HaveLen(15)) + Expect(ledgers.V2LedgerListResponse.Cursor.Data).To(HaveLen(15)) }) - It("filtering on bucket should return 5 ledgers", func() { - ledgers, err := ListLedgers(ctx, testServer.GetValue(), operations.V2ListLedgersRequest{ + It("filtering on bucket should return 5 ledgers", func(specContext SpecContext) { + ledgers, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.ListLedgers(ctx, operations.V2ListLedgersRequest{ PageSize: pointer.For(int64(100)), RequestBody: map[string]any{ "$match": map[string]any{ @@ -65,10 +66,10 @@ var _ = Context("Ledger engine tests", func() { }, }) Expect(err).To(BeNil()) - Expect(ledgers.Data).To(HaveLen(10)) + Expect(ledgers.V2LedgerListResponse.Cursor.Data).To(HaveLen(10)) }) - It("filtering on metadata[foo] = 0 should return 7 ledgers", func() { - ledgers, err := ListLedgers(ctx, testServer.GetValue(), operations.V2ListLedgersRequest{ + It("filtering on metadata[foo] = 0 should return 7 ledgers", func(specContext SpecContext) { + ledgers, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.ListLedgers(ctx, operations.V2ListLedgersRequest{ PageSize: pointer.For(int64(100)), RequestBody: map[string]any{ "$match": map[string]any{ @@ -77,10 +78,10 @@ var _ = Context("Ledger engine tests", func() { }, }) Expect(err).To(BeNil()) - Expect(ledgers.Data).To(HaveLen(7)) + Expect(ledgers.V2LedgerListResponse.Cursor.Data).To(HaveLen(7)) }) - It("filtering on name = ledger0 should return 1 ledger", func() { - ledgers, err := ListLedgers(ctx, testServer.GetValue(), operations.V2ListLedgersRequest{ + It("filtering on name = ledger0 should return 1 ledger", func(specContext SpecContext) { + ledgers, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.ListLedgers(ctx, operations.V2ListLedgersRequest{ PageSize: pointer.For(int64(100)), RequestBody: map[string]any{ "$match": map[string]any{ @@ -89,10 +90,10 @@ var _ = Context("Ledger engine tests", func() { }, }) Expect(err).To(BeNil()) - Expect(ledgers.Data).To(HaveLen(1)) + Expect(ledgers.V2LedgerListResponse.Cursor.Data).To(HaveLen(1)) }) - It("filtering on name starting with ledger1 should return 11 ledger", func() { - ledgers, err := ListLedgers(ctx, testServer.GetValue(), operations.V2ListLedgersRequest{ + It("filtering on name starting with ledger1 should return 11 ledger", func(specContext SpecContext) { + ledgers, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.ListLedgers(ctx, operations.V2ListLedgersRequest{ PageSize: pointer.For(int64(100)), RequestBody: map[string]any{ "$like": map[string]any{ @@ -101,7 +102,7 @@ var _ = Context("Ledger engine tests", func() { }, }) Expect(err).To(BeNil()) - Expect(ledgers.Data).To(HaveLen(11)) + Expect(ledgers.V2LedgerListResponse.Cursor.Data).To(HaveLen(11)) }) }) }) diff --git a/test/e2e/api_ledgers_metadata_test.go b/test/e2e/api_ledgers_metadata_test.go index 82d7210658..fb6a4a7cb3 100644 --- a/test/e2e/api_ledgers_metadata_test.go +++ b/test/e2e/api_ledgers_metadata_test.go @@ -4,11 +4,12 @@ package test_suite import ( "github.com/formancehq/go-libs/v2/logging" - "github.com/formancehq/go-libs/v2/testing/deferred" + . "github.com/formancehq/go-libs/v2/testing/deferred/ginkgo" "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" "github.com/formancehq/go-libs/v2/testing/testservice" "github.com/formancehq/ledger/pkg/client/models/operations" . "github.com/formancehq/ledger/pkg/testserver" + "github.com/formancehq/ledger/pkg/testserver/ginkgo" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -19,8 +20,8 @@ var _ = Context("Ledger engine tests", func() { ctx = logging.TestingContext() ) - testServer := DeferTestServer( - deferred.DeferMap(db, (*pgtesting.Database).ConnectionOptions), + testServer := ginkgo.DeferTestServer( + DeferMap(db, (*pgtesting.Database).ConnectionOptions), testservice.WithInstruments( testservice.DebugInstrumentation(debug), testservice.OutputInstrumentation(GinkgoWriter), @@ -29,8 +30,8 @@ var _ = Context("Ledger engine tests", func() { ) When("creating a ledger", func() { - BeforeEach(func() { - err := CreateLedger(ctx, testServer.GetValue(), operations.V2CreateLedgerRequest{ + BeforeEach(func(specContext SpecContext) { + _, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.CreateLedger(ctx, operations.V2CreateLedgerRequest{ Ledger: "default", }) Expect(err).To(BeNil()) @@ -39,34 +40,34 @@ var _ = Context("Ledger engine tests", func() { m := map[string]string{ "foo": "bar", } - BeforeEach(func() { - err := UpdateLedgerMetadata(ctx, testServer.GetValue(), operations.V2UpdateLedgerMetadataRequest{ + BeforeEach(func(specContext SpecContext) { + _, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.UpdateLedgerMetadata(ctx, operations.V2UpdateLedgerMetadataRequest{ Ledger: "default", RequestBody: m, }) Expect(err).To(BeNil()) }) - It("should be ok", func() { - ledger, err := GetLedger(ctx, testServer.GetValue(), operations.V2GetLedgerRequest{ + It("should be ok", func(specContext SpecContext) { + ledger, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.GetLedger(ctx, operations.V2GetLedgerRequest{ Ledger: "default", }) Expect(err).To(BeNil()) - Expect(ledger.Metadata).To(Equal(m)) + Expect(ledger.V2GetLedgerResponse.Data.Metadata).To(Equal(m)) }) When("deleting metadata", func() { - BeforeEach(func() { - err := DeleteLedgerMetadata(ctx, testServer.GetValue(), operations.V2DeleteLedgerMetadataRequest{ + BeforeEach(func(specContext SpecContext) { + _, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.DeleteLedgerMetadata(ctx, operations.V2DeleteLedgerMetadataRequest{ Ledger: "default", Key: "foo", }) Expect(err).To(BeNil()) }) - It("should be ok", func() { - ledger, err := GetLedger(ctx, testServer.GetValue(), operations.V2GetLedgerRequest{ + It("should be ok", func(specContext SpecContext) { + ledger, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.GetLedger(ctx, operations.V2GetLedgerRequest{ Ledger: "default", }) Expect(err).To(BeNil()) - Expect(ledger.Metadata).To(BeEmpty()) + Expect(ledger.V2GetLedgerResponse.Data.Metadata).To(BeEmpty()) }) }) }) diff --git a/test/e2e/api_logs_list_test.go b/test/e2e/api_logs_list_test.go index d06f44b158..7c30b18e7b 100644 --- a/test/e2e/api_logs_list_test.go +++ b/test/e2e/api_logs_list_test.go @@ -6,12 +6,13 @@ import ( "fmt" "github.com/formancehq/go-libs/v2/logging" "github.com/formancehq/go-libs/v2/pointer" - "github.com/formancehq/go-libs/v2/testing/deferred" + . "github.com/formancehq/go-libs/v2/testing/deferred/ginkgo" "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" "github.com/formancehq/go-libs/v2/testing/testservice" "github.com/formancehq/ledger/pkg/client/models/components" "github.com/formancehq/ledger/pkg/client/models/operations" . "github.com/formancehq/ledger/pkg/testserver" + "github.com/formancehq/ledger/pkg/testserver/ginkgo" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "math/big" @@ -25,8 +26,8 @@ var _ = Context("Ledger logs list API tests", func() { ctx = logging.TestingContext() ) - testServer := DeferTestServer( - deferred.DeferMap(db, (*pgtesting.Database).ConnectionOptions), + testServer := ginkgo.DeferTestServer( + DeferMap(db, (*pgtesting.Database).ConnectionOptions), testservice.WithInstruments( testservice.DebugInstrumentation(debug), testservice.OutputInstrumentation(GinkgoWriter), @@ -34,13 +35,13 @@ var _ = Context("Ledger logs list API tests", func() { testservice.WithLogger(GinkgoT()), ) - BeforeEach(func() { - err := CreateLedger(ctx, testServer.GetValue(), operations.V2CreateLedgerRequest{ + BeforeEach(func(specContext SpecContext) { + _, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.CreateLedger(ctx, operations.V2CreateLedgerRequest{ Ledger: "default", }) Expect(err).To(BeNil()) - err = CreateLedger(ctx, testServer.GetValue(), operations.V2CreateLedgerRequest{ + _, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.CreateLedger(ctx, operations.V2CreateLedgerRequest{ Ledger: "another", }) Expect(err).To(BeNil()) @@ -57,10 +58,9 @@ var _ = Context("Ledger logs list API tests", func() { "clientType": "gold", } ) - BeforeEach(func() { - _, err := CreateTransaction( + BeforeEach(func(specContext SpecContext) { + _, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.CreateTransaction( ctx, - testServer.GetValue(), operations.V2CreateTransactionRequest{ V2PostTransaction: components.V2PostTransaction{ Metadata: map[string]string{}, @@ -77,9 +77,8 @@ var _ = Context("Ledger logs list API tests", func() { ) Expect(err).ToNot(HaveOccurred()) - _, err = CreateTransaction( + _, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.CreateTransaction( ctx, - testServer.GetValue(), operations.V2CreateTransactionRequest{ V2PostTransaction: components.V2PostTransaction{ Metadata: map[string]string{}, @@ -96,9 +95,8 @@ var _ = Context("Ledger logs list API tests", func() { ) Expect(err).ToNot(HaveOccurred()) - _, err = CreateTransaction( + _, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.CreateTransaction( ctx, - testServer.GetValue(), operations.V2CreateTransactionRequest{ V2PostTransaction: components.V2PostTransaction{ Metadata: m1, @@ -115,9 +113,8 @@ var _ = Context("Ledger logs list API tests", func() { ) Expect(err).ToNot(HaveOccurred()) - err = AddMetadataToAccount( + _, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.AddMetadataToAccount( ctx, - testServer.GetValue(), operations.V2AddMetadataToAccountRequest{ RequestBody: m2, Address: "foo:baz", @@ -126,27 +123,26 @@ var _ = Context("Ledger logs list API tests", func() { ) Expect(err).ToNot(HaveOccurred()) }) - It("should be listed on api with ListLogs", func() { - response, err := ListLogs( + It("should be listed on api with ListLogs", func(specContext SpecContext) { + response, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.ListLogs( ctx, - testServer.GetValue(), operations.V2ListLogsRequest{ Ledger: "default", }, ) Expect(err).ToNot(HaveOccurred()) - Expect(response.Data).To(HaveLen(3)) + Expect(response.V2LogsCursorResponse.Cursor.Data).To(HaveLen(3)) - for _, data := range response.Data { + for _, data := range response.V2LogsCursorResponse.Cursor.Data { Expect(data.Hash).NotTo(BeEmpty()) } // Cannot check the date and the hash since they are changing at // every run - Expect(response.Data[0].ID).To(Equal(big.NewInt(3))) - Expect(response.Data[0].Type).To(Equal(components.V2LogTypeSetMetadata)) - Expect(response.Data[0].Data).To(Equal(map[string]any{ + Expect(response.V2LogsCursorResponse.Cursor.Data[0].ID).To(Equal(big.NewInt(3))) + Expect(response.V2LogsCursorResponse.Cursor.Data[0].Type).To(Equal(components.V2LogTypeSetMetadata)) + Expect(response.V2LogsCursorResponse.Cursor.Data[0].Data).To(Equal(map[string]any{ "targetType": "ACCOUNT", "metadata": map[string]any{ "clientType": "gold", @@ -154,13 +150,13 @@ var _ = Context("Ledger logs list API tests", func() { "targetId": "foo:baz", })) - Expect(response.Data[1].ID).To(Equal(big.NewInt(2))) - Expect(response.Data[1].Type).To(Equal(components.V2LogTypeNewTransaction)) + Expect(response.V2LogsCursorResponse.Cursor.Data[1].ID).To(Equal(big.NewInt(2))) + Expect(response.V2LogsCursorResponse.Cursor.Data[1].Type).To(Equal(components.V2LogTypeNewTransaction)) // Cannot check date and txid inside Data since they are changing at // every run - Expect(response.Data[1].Data["accountMetadata"]).To(Equal(map[string]any{})) - Expect(response.Data[1].Data["transaction"]).To(BeAssignableToTypeOf(map[string]any{})) - transaction := response.Data[1].Data["transaction"].(map[string]any) + Expect(response.V2LogsCursorResponse.Cursor.Data[1].Data["accountMetadata"]).To(Equal(map[string]any{})) + Expect(response.V2LogsCursorResponse.Cursor.Data[1].Data["transaction"]).To(BeAssignableToTypeOf(map[string]any{})) + transaction := response.V2LogsCursorResponse.Cursor.Data[1].Data["transaction"].(map[string]any) Expect(transaction["metadata"]).To(Equal(map[string]any{ "clientType": "silver", })) @@ -174,11 +170,11 @@ var _ = Context("Ledger logs list API tests", func() { }, })) - Expect(response.Data[2].ID).To(Equal(big.NewInt(1))) - Expect(response.Data[2].Type).To(Equal(components.V2LogTypeNewTransaction)) - Expect(response.Data[2].Data["accountMetadata"]).To(Equal(map[string]any{})) - Expect(response.Data[2].Data["transaction"]).To(BeAssignableToTypeOf(map[string]any{})) - transaction = response.Data[2].Data["transaction"].(map[string]any) + Expect(response.V2LogsCursorResponse.Cursor.Data[2].ID).To(Equal(big.NewInt(1))) + Expect(response.V2LogsCursorResponse.Cursor.Data[2].Type).To(Equal(components.V2LogTypeNewTransaction)) + Expect(response.V2LogsCursorResponse.Cursor.Data[2].Data["accountMetadata"]).To(Equal(map[string]any{})) + Expect(response.V2LogsCursorResponse.Cursor.Data[2].Data["transaction"]).To(BeAssignableToTypeOf(map[string]any{})) + transaction = response.V2LogsCursorResponse.Cursor.Data[2].Data["transaction"].(map[string]any) Expect(transaction["metadata"]).To(Equal(map[string]any{})) Expect(transaction["timestamp"]).To(Equal("2023-04-11T10:00:00Z")) Expect(transaction["postings"]).To(Equal([]any{ @@ -218,13 +214,12 @@ var _ = Context("Ledger logs list API tests", func() { var ( expectedLogs []expectedLog ) - BeforeEach(func() { + BeforeEach(func(specContext SpecContext) { for i := int64(0); i < accountCounts; i++ { now := time.Now().Round(time.Millisecond).UTC() - _, err := CreateTransaction( + _, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.CreateTransaction( ctx, - testServer.GetValue(), operations.V2CreateTransactionRequest{ V2PostTransaction: components.V2PostTransaction{ Metadata: map[string]string{}, @@ -264,13 +259,12 @@ var _ = Context("Ledger logs list API tests", func() { }) When(fmt.Sprintf("listing accounts using page size of %d", pageSize), func() { var ( - rsp *components.V2LogsCursorResponseCursor + rsp *operations.V2ListLogsResponse err error ) - BeforeEach(func() { - rsp, err = ListLogs( + BeforeEach(func(specContext SpecContext) { + rsp, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.ListLogs( ctx, - testServer.GetValue(), operations.V2ListLogsRequest{ Ledger: "default", PageSize: pointer.For(pageSize), @@ -278,56 +272,54 @@ var _ = Context("Ledger logs list API tests", func() { ) Expect(err).ToNot(HaveOccurred()) - Expect(rsp.HasMore).To(BeTrue()) - Expect(rsp.Previous).To(BeNil()) - Expect(rsp.Next).NotTo(BeNil()) + Expect(rsp.V2LogsCursorResponse.Cursor.HasMore).To(BeTrue()) + Expect(rsp.V2LogsCursorResponse.Cursor.Previous).To(BeNil()) + Expect(rsp.V2LogsCursorResponse.Cursor.Next).NotTo(BeNil()) }) It("should return the first page", func() { - Expect(rsp.PageSize).To(Equal(pageSize)) - Expect(len(rsp.Data)).To(Equal(len(expectedLogs[:pageSize]))) - for i := range rsp.Data { - compareLogs(rsp.Data[i], expectedLogs[i]) + Expect(rsp.V2LogsCursorResponse.Cursor.PageSize).To(Equal(pageSize)) + Expect(len(rsp.V2LogsCursorResponse.Cursor.Data)).To(Equal(len(expectedLogs[:pageSize]))) + for i := range rsp.V2LogsCursorResponse.Cursor.Data { + compareLogs(rsp.V2LogsCursorResponse.Cursor.Data[i], expectedLogs[i]) } }) When("following next cursor", func() { - BeforeEach(func() { - rsp, err = ListLogs( + BeforeEach(func(specContext SpecContext) { + rsp, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.ListLogs( ctx, - testServer.GetValue(), operations.V2ListLogsRequest{ - Cursor: rsp.Next, + Cursor: rsp.V2LogsCursorResponse.Cursor.Next, Ledger: "default", }, ) Expect(err).ToNot(HaveOccurred()) }) It("should return next page", func() { - Expect(rsp.PageSize).To(Equal(pageSize)) - Expect(len(rsp.Data)).To(Equal(len(expectedLogs[pageSize : 2*pageSize]))) - for i := range rsp.Data { - compareLogs(rsp.Data[i], expectedLogs[int64(i)+pageSize]) + Expect(rsp.V2LogsCursorResponse.Cursor.PageSize).To(Equal(pageSize)) + Expect(len(rsp.V2LogsCursorResponse.Cursor.Data)).To(Equal(len(expectedLogs[pageSize : 2*pageSize]))) + for i := range rsp.V2LogsCursorResponse.Cursor.Data { + compareLogs(rsp.V2LogsCursorResponse.Cursor.Data[i], expectedLogs[int64(i)+pageSize]) } - Expect(rsp.Next).To(BeNil()) + Expect(rsp.V2LogsCursorResponse.Cursor.Next).To(BeNil()) }) When("following previous cursor", func() { - BeforeEach(func() { - rsp, err = ListLogs( + BeforeEach(func(specContext SpecContext) { + rsp, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.ListLogs( ctx, - testServer.GetValue(), operations.V2ListLogsRequest{ - Cursor: rsp.Previous, + Cursor: rsp.V2LogsCursorResponse.Cursor.Previous, Ledger: "default", }, ) Expect(err).ToNot(HaveOccurred()) }) It("should return first page", func() { - Expect(rsp.PageSize).To(Equal(pageSize)) - Expect(len(rsp.Data)).To(Equal(len(expectedLogs[:pageSize]))) - for i := range rsp.Data { - compareLogs(rsp.Data[i], expectedLogs[i]) + Expect(rsp.V2LogsCursorResponse.Cursor.PageSize).To(Equal(pageSize)) + Expect(len(rsp.V2LogsCursorResponse.Cursor.Data)).To(Equal(len(expectedLogs[:pageSize]))) + for i := range rsp.V2LogsCursorResponse.Cursor.Data { + compareLogs(rsp.V2LogsCursorResponse.Cursor.Data[i], expectedLogs[i]) } - Expect(rsp.Previous).To(BeNil()) + Expect(rsp.V2LogsCursorResponse.Cursor.Previous).To(BeNil()) }) }) }) diff --git a/test/e2e/api_transactions_create_test.go b/test/e2e/api_transactions_create_test.go index bf3dd5a2e3..9f2e55c1ff 100644 --- a/test/e2e/api_transactions_create_test.go +++ b/test/e2e/api_transactions_create_test.go @@ -3,10 +3,12 @@ package test_suite import ( - "github.com/formancehq/go-libs/v2/testing/deferred" + "github.com/formancehq/go-libs/v2/testing/deferred/ginkgo" + . "github.com/formancehq/go-libs/v2/testing/deferred/ginkgo" "github.com/formancehq/go-libs/v2/testing/platform/natstesting" "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" "github.com/formancehq/go-libs/v2/testing/testservice" + . "github.com/formancehq/ledger/pkg/testserver/ginkgo" "math/big" "time" @@ -38,7 +40,7 @@ var _ = Context("Ledger transactions create API tests", func() { var ( db = UseTemplatedDatabase() ctx = logging.TestingContext() - natsURL = deferred.DeferMap(natsServer, (*natstesting.NatsServer).ClientURL) + natsURL = ginkgo.DeferMap(natsServer, (*natstesting.NatsServer).ClientURL) ) instruments := []testservice.Instrumentation{ testservice.NatsInstrumentation(natsURL), @@ -49,18 +51,18 @@ var _ = Context("Ledger transactions create API tests", func() { instruments = append(instruments, ExperimentalNumscriptRewriteInstrumentation()) } testServer := DeferTestServer( - deferred.DeferMap(db, (*pgtesting.Database).ConnectionOptions), + ginkgo.DeferMap(db, (*pgtesting.Database).ConnectionOptions), testservice.WithInstruments(instruments...), testservice.WithLogger(GinkgoT()), ) - BeforeEach(func() { - err := CreateLedger(ctx, testServer.GetValue(), operations.V2CreateLedgerRequest{ + BeforeEach(func(specContext SpecContext) { + _, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.CreateLedger(ctx, operations.V2CreateLedgerRequest{ Ledger: "default", }) Expect(err).To(BeNil()) - err = CreateLedger(ctx, testServer.GetValue(), operations.V2CreateLedgerRequest{ + _, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.CreateLedger(ctx, operations.V2CreateLedgerRequest{ Ledger: "test", }) Expect(err).To(BeNil()) @@ -70,12 +72,12 @@ var _ = Context("Ledger transactions create API tests", func() { var ( events chan *nats.Msg timestamp = time.Now().Round(time.Second).UTC() - rsp *components.V2Transaction + rsp *operations.V2CreateTransactionResponse req operations.V2CreateTransactionRequest err error ) - BeforeEach(func() { - _, events = Subscribe(GinkgoT(), testServer.GetValue(), natsURL) + BeforeEach(func(specContext SpecContext) { + _, events = Subscribe(specContext, testServer, natsURL) req = operations.V2CreateTransactionRequest{ V2PostTransaction: components.V2PostTransaction{ Timestamp: ×tamp, @@ -83,13 +85,13 @@ var _ = Context("Ledger transactions create API tests", func() { Ledger: "default", } }) - JustBeforeEach(func() { + JustBeforeEach(func(specContext SpecContext) { // Create a transaction - rsp, err = CreateTransaction(ctx, testServer.GetValue(), req) + rsp, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.CreateTransaction(ctx, req) }) Context("overriding an account metadata", func() { - BeforeEach(func() { - err := AddMetadataToAccount(ctx, testServer.GetValue(), operations.V2AddMetadataToAccountRequest{ + BeforeEach(func(specContext SpecContext) { + _, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.AddMetadataToAccount(ctx, operations.V2AddMetadataToAccountRequest{ Address: "alice", Ledger: "default", RequestBody: map[string]string{ @@ -109,27 +111,27 @@ var _ = Context("Ledger transactions create API tests", func() { `, } }) - It("should override account metadata", func() { + It("should override account metadata", func(specContext SpecContext) { Expect(err).To(BeNil()) - account, err := GetAccount(ctx, testServer.GetValue(), operations.V2GetAccountRequest{ + account, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.GetAccount(ctx, operations.V2GetAccountRequest{ Address: "alice", Ledger: "default", }) Expect(err).ToNot(HaveOccurred()) - Expect(*account).Should(Equal(components.V2Account{ + Expect(account.V2AccountResponse.Data).Should(Equal(components.V2Account{ Address: "alice", Metadata: map[string]string{ "clientType": "silver", }, })) - account, err = GetAccount(ctx, testServer.GetValue(), operations.V2GetAccountRequest{ + account, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.GetAccount(ctx, operations.V2GetAccountRequest{ Address: "foo", Ledger: "default", }) Expect(err).ToNot(HaveOccurred()) - Expect(*account).Should(Equal(components.V2Account{ + Expect(account.V2AccountResponse.Data).Should(Equal(components.V2Account{ Address: "foo", Metadata: map[string]string{ "status": "pending", @@ -161,22 +163,22 @@ var _ = Context("Ledger transactions create API tests", func() { Ledger: "default", } }) - It("should be ok", func() { - alice, err := GetAccount(ctx, testServer.GetValue(), operations.V2GetAccountRequest{ + It("should be ok", func(specContext SpecContext) { + alice, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.GetAccount(ctx, operations.V2GetAccountRequest{ Address: "alice", Ledger: "default", }) Expect(err).To(BeNil()) - Expect(alice.Metadata).To(Equal(map[string]string{ + Expect(alice.V2AccountResponse.Data.Metadata).To(Equal(map[string]string{ "foo": "baz", })) - world, err := GetAccount(ctx, testServer.GetValue(), operations.V2GetAccountRequest{ + world, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.GetAccount(ctx, operations.V2GetAccountRequest{ Address: "world", Ledger: "default", }) Expect(err).To(BeNil()) - Expect(world.Metadata).To(Equal(map[string]string{ + Expect(world.V2AccountResponse.Data.Metadata).To(Equal(map[string]string{ "foo": "bar", })) }) @@ -203,25 +205,24 @@ var _ = Context("Ledger transactions create API tests", func() { Ledger: "default", } }) - It("should be ok", func() { - response, err := GetTransaction( + It("should be ok", func(specContext SpecContext) { + response, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.GetTransaction( ctx, - testServer.GetValue(), operations.V2GetTransactionRequest{ Ledger: "default", - ID: rsp.ID, + ID: rsp.V2CreateTransactionResponse.Data.ID, Expand: pointer.For("volumes"), }, ) Expect(err).ToNot(HaveOccurred()) - Expect(*response).To(Equal(components.V2Transaction{ - Timestamp: rsp.Timestamp, - InsertedAt: rsp.InsertedAt, - Postings: rsp.Postings, - Reference: rsp.Reference, - Metadata: rsp.Metadata, - ID: rsp.ID, + Expect(response.V2GetTransactionResponse.Data).To(Equal(components.V2Transaction{ + Timestamp: rsp.V2CreateTransactionResponse.Data.Timestamp, + InsertedAt: rsp.V2CreateTransactionResponse.Data.InsertedAt, + Postings: rsp.V2CreateTransactionResponse.Data.Postings, + Reference: rsp.V2CreateTransactionResponse.Data.Reference, + Metadata: rsp.V2CreateTransactionResponse.Data.Metadata, + ID: rsp.V2CreateTransactionResponse.Data.ID, PreCommitVolumes: map[string]map[string]components.V2Volume{ "world": { "USD": { @@ -256,9 +257,8 @@ var _ = Context("Ledger transactions create API tests", func() { }, })) - account, err := GetAccount( + account, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.GetAccount( ctx, - testServer.GetValue(), operations.V2GetAccountRequest{ Address: "alice", Ledger: "default", @@ -267,7 +267,7 @@ var _ = Context("Ledger transactions create API tests", func() { ) Expect(err).ToNot(HaveOccurred()) - Expect(*account).Should(Equal(components.V2Account{ + Expect(account.V2AccountResponse.Data).Should(Equal(components.V2Account{ Address: "alice", Metadata: metadata.Metadata{}, Volumes: map[string]components.V2Volume{ @@ -281,7 +281,7 @@ var _ = Context("Ledger transactions create API tests", func() { By("should trigger a new event", func() { Eventually(events).Should(Receive(Event(ledgerevents.EventTypeCommittedTransactions, WithPayload(bus.CommittedTransactions{ Ledger: "default", - Transactions: []ledger.Transaction{ConvertSDKTxToCoreTX(rsp)}, + Transactions: []ledger.Transaction{ConvertSDKTxToCoreTX(&rsp.V2CreateTransactionResponse.Data)}, AccountMetadata: ledger.AccountMetadata{}, })))) }) @@ -294,8 +294,8 @@ var _ = Context("Ledger transactions create API tests", func() { Expect(err).To(BeNil()) }) When("trying to commit a new transaction with the same reference", func() { - JustBeforeEach(func() { - _, err = CreateTransaction(ctx, testServer.GetValue(), req) + JustBeforeEach(func(specContext SpecContext) { + _, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.CreateTransaction(ctx, req) Expect(err).To(HaveOccurred()) Expect(err).To(HaveErrorCode(string(components.V2ErrorsEnumConflict))) }) @@ -415,15 +415,15 @@ var _ = Context("Ledger transactions create API tests", func() { }) It("should be ok", func() { Expect(err).To(Succeed()) - Expect(rsp.ID).To(Equal(big.NewInt(1))) + Expect(rsp.V2CreateTransactionResponse.Data.ID).To(Equal(big.NewInt(1))) }) When("creating a ledger transaction with same ik and different ledger", func() { - JustBeforeEach(func() { - rsp, err = CreateTransaction(ctx, testServer.GetValue(), req) + JustBeforeEach(func(specContext SpecContext) { + rsp, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.CreateTransaction(ctx, req) }) It("should not have an error", func() { Expect(err).To(Succeed()) - Expect(rsp.ID).To(Equal(big.NewInt(1))) + Expect(rsp.V2CreateTransactionResponse.Data.ID).To(Equal(big.NewInt(1))) }) }) }) @@ -595,9 +595,12 @@ var _ = Context("Ledger transactions create API tests", func() { err error response *operations.CreateTransactionResponse ) - BeforeEach(func() { + BeforeEach(func(specContext SpecContext) { v, _ := big.NewInt(0).SetString("1320000000000000000000000000000000000000000000000001", 10) - response, err = Client(testServer.GetValue()).Ledger.V1.CreateTransaction( + testServer, err := testServer.Wait(specContext) + Expect(err).To(BeNil()) + + response, err = Client(testServer).Ledger.V1.CreateTransaction( ctx, operations.CreateTransactionRequest{ PostTransaction: components.PostTransaction{ @@ -621,6 +624,7 @@ var _ = Context("Ledger transactions create API tests", func() { Ledger: "default", }, ) + Expect(err).To(BeNil()) }) It("should be ok", func() { Expect(err).To(Succeed()) diff --git a/test/e2e/api_transactions_list_test.go b/test/e2e/api_transactions_list_test.go index 25f381a68f..14aacb068b 100644 --- a/test/e2e/api_transactions_list_test.go +++ b/test/e2e/api_transactions_list_test.go @@ -8,7 +8,7 @@ import ( "github.com/formancehq/go-libs/v2/logging" "github.com/formancehq/go-libs/v2/query" . "github.com/formancehq/go-libs/v2/testing/api" - "github.com/formancehq/go-libs/v2/testing/deferred" + . "github.com/formancehq/go-libs/v2/testing/deferred/ginkgo" "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" "github.com/formancehq/go-libs/v2/testing/testservice" libtime "github.com/formancehq/go-libs/v2/time" @@ -16,6 +16,7 @@ import ( "github.com/formancehq/ledger/pkg/client/models/components" "github.com/formancehq/ledger/pkg/client/models/operations" . "github.com/formancehq/ledger/pkg/testserver" + "github.com/formancehq/ledger/pkg/testserver/ginkgo" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "math/big" @@ -32,8 +33,8 @@ var _ = Context("Ledger transactions list API tests", func() { ctx = logging.TestingContext() ) - testServer := DeferTestServer( - deferred.DeferMap(db, (*pgtesting.Database).ConnectionOptions), + testServer := ginkgo.DeferTestServer( + DeferMap(db, (*pgtesting.Database).ConnectionOptions), testservice.WithInstruments( testservice.DebugInstrumentation(debug), testservice.OutputInstrumentation(GinkgoWriter), @@ -41,8 +42,8 @@ var _ = Context("Ledger transactions list API tests", func() { testservice.WithLogger(GinkgoT()), ) - JustBeforeEach(func() { - err := CreateLedger(ctx, testServer.GetValue(), operations.V2CreateLedgerRequest{ + JustBeforeEach(func(specContext SpecContext) { + _, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.CreateLedger(ctx, operations.V2CreateLedgerRequest{ Ledger: "default", }) Expect(err).To(BeNil()) @@ -56,7 +57,7 @@ var _ = Context("Ledger transactions list API tests", func() { timestamp = time.Now() transactions []components.V2Transaction ) - JustBeforeEach(func() { + JustBeforeEach(func(specContext SpecContext) { for i := 0; i < int(txCount); i++ { offset := time.Duration(int(txCount)-i) * time.Minute // 1 transaction of 2 is backdated to test pagination using effective date @@ -67,9 +68,8 @@ var _ = Context("Ledger transactions list API tests", func() { } txTimestamp := timestamp.Add(-offset) - response, err := CreateTransaction( + response, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.CreateTransaction( ctx, - testServer.GetValue(), operations.V2CreateTransactionRequest{ V2PostTransaction: components.V2PostTransaction{ Metadata: map[string]string{}, @@ -96,7 +96,7 @@ var _ = Context("Ledger transactions list API tests", func() { Expect(err).ToNot(HaveOccurred()) transactions = append([]components.V2Transaction{ - *response, + response.V2CreateTransactionResponse.Data, }, transactions...) } }) @@ -105,7 +105,7 @@ var _ = Context("Ledger transactions list API tests", func() { }) When(fmt.Sprintf("listing transactions using page size of %d", pageSize), func() { var ( - rsp *components.V2TransactionsCursorResponseCursor + rsp *operations.V2ListTransactionsResponse req operations.V2ListTransactionsRequest err error ) @@ -133,8 +133,8 @@ var _ = Context("Ledger transactions list API tests", func() { }, } }) - JustBeforeEach(func() { - rsp, err = ListTransactions(ctx, testServer.GetValue(), req) + JustBeforeEach(func(specContext SpecContext) { + rsp, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.ListTransactions(ctx, req) Expect(err).ToNot(HaveOccurred()) }) Context("with a filter on reference", func() { @@ -146,8 +146,8 @@ var _ = Context("Ledger transactions list API tests", func() { } }) It("Should be ok, and returns transactions with reference 'ref-0'", func() { - Expect(rsp.Data).To(HaveLen(1)) - Expect(rsp.Data[0]).To(Equal(transactions[txCount-1])) + Expect(rsp.V2TransactionsCursorResponse.Cursor.Data).To(HaveLen(1)) + Expect(rsp.V2TransactionsCursorResponse.Cursor.Data[0]).To(Equal(transactions[txCount-1])) }) }) Context("with effective ordering", func() { @@ -155,28 +155,27 @@ var _ = Context("Ledger transactions list API tests", func() { req.Order = pointer.For(operations.OrderEffective) }) It("Should be ok, and returns transactions ordered by effective timestamp", func() { - Expect(rsp.PageSize).To(Equal(pageSize)) + Expect(rsp.V2TransactionsCursorResponse.Cursor.PageSize).To(Equal(pageSize)) sorted := transactions[:pageSize] sort.SliceStable(sorted, func(i, j int) bool { return sorted[i].Timestamp.After(sorted[j].Timestamp) }) - Expect(rsp.Data).To(Equal(sorted)) + Expect(rsp.V2TransactionsCursorResponse.Cursor.Data).To(Equal(sorted)) }) }) It("Should be ok", func() { - Expect(rsp.PageSize).To(Equal(pageSize)) - Expect(rsp.Data).To(Equal(transactions[:pageSize])) + Expect(rsp.V2TransactionsCursorResponse.Cursor.PageSize).To(Equal(pageSize)) + Expect(rsp.V2TransactionsCursorResponse.Cursor.Data).To(Equal(transactions[:pageSize])) }) When("following next cursor", func() { - JustBeforeEach(func() { - Expect(rsp.HasMore).To(BeTrue()) - Expect(rsp.Previous).To(BeNil()) - Expect(rsp.Next).NotTo(BeNil()) + JustBeforeEach(func(specContext SpecContext) { + Expect(rsp.V2TransactionsCursorResponse.Cursor.HasMore).To(BeTrue()) + Expect(rsp.V2TransactionsCursorResponse.Cursor.Previous).To(BeNil()) + Expect(rsp.V2TransactionsCursorResponse.Cursor.Next).NotTo(BeNil()) // Create a new transaction to ensure cursor is stable - _, err := CreateTransaction( + _, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.CreateTransaction( ctx, - testServer.GetValue(), operations.V2CreateTransactionRequest{ V2PostTransaction: components.V2PostTransaction{ Metadata: map[string]string{}, @@ -195,38 +194,36 @@ var _ = Context("Ledger transactions list API tests", func() { ) Expect(err).ToNot(HaveOccurred()) - rsp, err = ListTransactions( + rsp, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.ListTransactions( ctx, - testServer.GetValue(), operations.V2ListTransactionsRequest{ - Cursor: rsp.Next, + Cursor: rsp.V2TransactionsCursorResponse.Cursor.Next, Ledger: "default", }, ) Expect(err).ToNot(HaveOccurred()) }) It("should return next page", func() { - Expect(rsp.PageSize).To(Equal(pageSize)) - Expect(rsp.Data).To(Equal(transactions[pageSize : 2*pageSize])) - Expect(rsp.Next).To(BeNil()) + Expect(rsp.V2TransactionsCursorResponse.Cursor.PageSize).To(Equal(pageSize)) + Expect(rsp.V2TransactionsCursorResponse.Cursor.Data).To(Equal(transactions[pageSize : 2*pageSize])) + Expect(rsp.V2TransactionsCursorResponse.Cursor.Next).To(BeNil()) }) When("following previous cursor", func() { - JustBeforeEach(func() { + JustBeforeEach(func(specContext SpecContext) { var err error - rsp, err = ListTransactions( + rsp, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.ListTransactions( ctx, - testServer.GetValue(), operations.V2ListTransactionsRequest{ - Cursor: rsp.Previous, + Cursor: rsp.V2TransactionsCursorResponse.Cursor.Previous, Ledger: "default", }, ) Expect(err).ToNot(HaveOccurred()) }) It("should return first page", func() { - Expect(rsp.PageSize).To(Equal(pageSize)) - Expect(rsp.Data).To(Equal(transactions[:pageSize])) - Expect(rsp.Previous).To(BeNil()) + Expect(rsp.V2TransactionsCursorResponse.Cursor.PageSize).To(Equal(pageSize)) + Expect(rsp.V2TransactionsCursorResponse.Cursor.Data).To(Equal(transactions[:pageSize])) + Expect(rsp.V2TransactionsCursorResponse.Cursor.Previous).To(BeNil()) }) }) }) @@ -235,13 +232,12 @@ var _ = Context("Ledger transactions list API tests", func() { When("listing transactions using filter on a single match", func() { var ( err error - response *components.V2TransactionsCursorResponseCursor + response *operations.V2ListTransactionsResponse now = time.Now().Round(time.Second).UTC() ) - JustBeforeEach(func() { - response, err = ListTransactions( + JustBeforeEach(func(specContext SpecContext) { + response, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.ListTransactions( ctx, - testServer.GetValue(), operations.V2ListTransactionsRequest{ RequestBody: map[string]interface{}{ "$match": map[string]any{ @@ -256,9 +252,9 @@ var _ = Context("Ledger transactions list API tests", func() { Expect(err).To(BeNil()) }) It("Should be ok", func() { - Expect(response.Next).NotTo(BeNil()) + Expect(response.V2TransactionsCursorResponse.Cursor.Next).NotTo(BeNil()) cursor := &common.ColumnPaginatedQuery[any]{} - Expect(bunpaginate.UnmarshalCursor(*response.Next, cursor)).To(BeNil()) + Expect(bunpaginate.UnmarshalCursor(*response.V2TransactionsCursorResponse.Cursor.Next, cursor)).To(BeNil()) Expect(cursor.PageSize).To(Equal(uint64(10))) Expect(cursor.Options).To(Equal(common.ResourceQuery[any]{ Builder: query.Match("source", "world"), @@ -269,13 +265,12 @@ var _ = Context("Ledger transactions list API tests", func() { When("listing transactions using filter on a single match", func() { var ( err error - response *components.V2TransactionsCursorResponseCursor + response *operations.V2ListTransactionsResponse now = time.Now().Round(time.Second).UTC() ) - JustBeforeEach(func() { - response, err = ListTransactions( + JustBeforeEach(func(specContext SpecContext) { + response, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.ListTransactions( ctx, - testServer.GetValue(), operations.V2ListTransactionsRequest{ RequestBody: map[string]interface{}{ "$and": []map[string]any{ @@ -299,9 +294,9 @@ var _ = Context("Ledger transactions list API tests", func() { Expect(err).To(BeNil()) }) It("Should be ok", func() { - Expect(response.Next).NotTo(BeNil()) + Expect(response.V2TransactionsCursorResponse.Cursor.Next).NotTo(BeNil()) cursor := &common.ColumnPaginatedQuery[any]{} - Expect(bunpaginate.UnmarshalCursor(*response.Next, cursor)).To(BeNil()) + Expect(bunpaginate.UnmarshalCursor(*response.V2TransactionsCursorResponse.Cursor.Next, cursor)).To(BeNil()) Expect(cursor.PageSize).To(Equal(uint64(10))) Expect(cursor.Options).To(Equal(common.ResourceQuery[any]{ Builder: query.And( @@ -316,10 +311,9 @@ var _ = Context("Ledger transactions list API tests", func() { var ( err error ) - JustBeforeEach(func() { - _, err = ListTransactions( + JustBeforeEach(func(specContext SpecContext) { + _, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.ListTransactions( ctx, - testServer.GetValue(), operations.V2ListTransactionsRequest{ RequestBody: map[string]interface{}{ "$match": map[string]any{ @@ -348,16 +342,15 @@ var _ = Context("Ledger transactions list API tests", func() { ) var ( - t1 *components.V2Transaction - t2 *components.V2Transaction - t3 *components.V2Transaction + t1 *operations.V2CreateTransactionResponse + t2 *operations.V2CreateTransactionResponse + t3 *operations.V2CreateTransactionResponse err error ) When("creating transactions", func() { - JustBeforeEach(func() { - t1, err = CreateTransaction( + JustBeforeEach(func(specContext SpecContext) { + t1, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.CreateTransaction( ctx, - testServer.GetValue(), operations.V2CreateTransactionRequest{ V2PostTransaction: components.V2PostTransaction{ Metadata: m1, @@ -376,9 +369,8 @@ var _ = Context("Ledger transactions list API tests", func() { ) Expect(err).ToNot(HaveOccurred()) - t2, err = CreateTransaction( + t2, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.CreateTransaction( ctx, - testServer.GetValue(), operations.V2CreateTransactionRequest{ V2PostTransaction: components.V2PostTransaction{ Metadata: m1, @@ -397,9 +389,8 @@ var _ = Context("Ledger transactions list API tests", func() { ) Expect(err).ToNot(HaveOccurred()) - t3, err = CreateTransaction( + t3, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.CreateTransaction( ctx, - testServer.GetValue(), operations.V2CreateTransactionRequest{ V2PostTransaction: components.V2PostTransaction{ Metadata: map[string]string{}, @@ -418,20 +409,18 @@ var _ = Context("Ledger transactions list API tests", func() { ) Expect(err).ToNot(HaveOccurred()) }) - It("should be countable on api", func() { - response, err := CountTransactions( + It("should be countable on api", func(specContext SpecContext) { + response, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.CountTransactions( ctx, - testServer.GetValue(), operations.V2CountTransactionsRequest{ Ledger: "default", }, ) Expect(err).ToNot(HaveOccurred()) - Expect(response).To(Equal(3)) + Expect(response.Headers["Count"]).To(Equal([]string{"3"})) - response, err = CountTransactions( + response, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.CountTransactions( ctx, - testServer.GetValue(), operations.V2CountTransactionsRequest{ Ledger: "default", RequestBody: map[string]interface{}{ @@ -442,11 +431,10 @@ var _ = Context("Ledger transactions list API tests", func() { }, ) Expect(err).ToNot(HaveOccurred()) - Expect(response).To(Equal(3)) + Expect(response.Headers["Count"]).To(Equal([]string{"3"})) - response, err = CountTransactions( + response, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.CountTransactions( ctx, - testServer.GetValue(), operations.V2CountTransactionsRequest{ Ledger: "default", RequestBody: map[string]interface{}{ @@ -457,11 +445,10 @@ var _ = Context("Ledger transactions list API tests", func() { }, ) Expect(err).ToNot(HaveOccurred()) - Expect(response).To(Equal(0)) + Expect(response.Headers["Count"]).To(Equal([]string{"0"})) - response, err = CountTransactions( + response, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.CountTransactions( ctx, - testServer.GetValue(), operations.V2CountTransactionsRequest{ Ledger: "default", RequestBody: map[string]interface{}{ @@ -472,11 +459,10 @@ var _ = Context("Ledger transactions list API tests", func() { }, ) Expect(err).ToNot(HaveOccurred()) - Expect(response).To(Equal(1)) + Expect(response.Headers["Count"]).To(Equal([]string{"1"})) - response, err = CountTransactions( + response, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.CountTransactions( ctx, - testServer.GetValue(), operations.V2CountTransactionsRequest{ Ledger: "default", RequestBody: map[string]interface{}{ @@ -487,11 +473,10 @@ var _ = Context("Ledger transactions list API tests", func() { }, ) Expect(err).ToNot(HaveOccurred()) - Expect(response).To(Equal(0)) + Expect(response.Headers["Count"]).To(Equal([]string{"0"})) - response, err = CountTransactions( + response, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.CountTransactions( ctx, - testServer.GetValue(), operations.V2CountTransactionsRequest{ Ledger: "default", RequestBody: map[string]interface{}{ @@ -502,11 +487,10 @@ var _ = Context("Ledger transactions list API tests", func() { }, ) Expect(err).ToNot(HaveOccurred()) - Expect(response).To(Equal(0)) + Expect(response.Headers["Count"]).To(Equal([]string{"0"})) - response, err = CountTransactions( + response, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.CountTransactions( ctx, - testServer.GetValue(), operations.V2CountTransactionsRequest{ Ledger: "default", RequestBody: map[string]interface{}{ @@ -517,11 +501,10 @@ var _ = Context("Ledger transactions list API tests", func() { }, ) Expect(err).ToNot(HaveOccurred()) - Expect(response).To(Equal(3)) + Expect(response.Headers["Count"]).To(Equal([]string{"3"})) - response, err = CountTransactions( + response, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.CountTransactions( ctx, - testServer.GetValue(), operations.V2CountTransactionsRequest{ Ledger: "default", RequestBody: map[string]interface{}{ @@ -532,11 +515,10 @@ var _ = Context("Ledger transactions list API tests", func() { }, ) Expect(err).ToNot(HaveOccurred()) - Expect(response).To(Equal(2)) + Expect(response.Headers["Count"]).To(Equal([]string{"2"})) - response, err = CountTransactions( + response, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.CountTransactions( ctx, - testServer.GetValue(), operations.V2CountTransactionsRequest{ Ledger: "default", RequestBody: map[string]interface{}{ @@ -547,11 +529,10 @@ var _ = Context("Ledger transactions list API tests", func() { }, ) Expect(err).ToNot(HaveOccurred()) - Expect(response).To(Equal(0)) + Expect(response.Headers["Count"]).To(Equal([]string{"0"})) - response, err = CountTransactions( + response, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.CountTransactions( ctx, - testServer.GetValue(), operations.V2CountTransactionsRequest{ Ledger: "default", RequestBody: map[string]interface{}{ @@ -562,11 +543,10 @@ var _ = Context("Ledger transactions list API tests", func() { }, ) Expect(err).ToNot(HaveOccurred()) - Expect(response).To(Equal(2)) + Expect(response.Headers["Count"]).To(Equal([]string{"2"})) - response, err = CountTransactions( + response, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.CountTransactions( ctx, - testServer.GetValue(), operations.V2CountTransactionsRequest{ Ledger: "default", RequestBody: map[string]interface{}{ @@ -577,11 +557,10 @@ var _ = Context("Ledger transactions list API tests", func() { }, ) Expect(err).ToNot(HaveOccurred()) - Expect(response).To(Equal(1)) + Expect(response.Headers["Count"]).To(Equal([]string{"1"})) - response, err = CountTransactions( + response, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.CountTransactions( ctx, - testServer.GetValue(), operations.V2CountTransactionsRequest{ Ledger: "default", RequestBody: map[string]interface{}{ @@ -592,11 +571,10 @@ var _ = Context("Ledger transactions list API tests", func() { }, ) Expect(err).ToNot(HaveOccurred()) - Expect(response).To(Equal(0)) + Expect(response.Headers["Count"]).To(Equal([]string{"0"})) - response, err = CountTransactions( + response, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.CountTransactions( ctx, - testServer.GetValue(), operations.V2CountTransactionsRequest{ Ledger: "default", RequestBody: map[string]interface{}{ @@ -607,11 +585,10 @@ var _ = Context("Ledger transactions list API tests", func() { }, ) Expect(err).ToNot(HaveOccurred()) - Expect(response).To(Equal(2)) + Expect(response.Headers["Count"]).To(Equal([]string{"2"})) - response, err = CountTransactions( + response, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.CountTransactions( ctx, - testServer.GetValue(), operations.V2CountTransactionsRequest{ Ledger: "default", RequestBody: map[string]interface{}{ @@ -622,11 +599,10 @@ var _ = Context("Ledger transactions list API tests", func() { }, ) Expect(err).ToNot(HaveOccurred()) - Expect(response).To(Equal(1)) + Expect(response.Headers["Count"]).To(Equal([]string{"1"})) - response, err = CountTransactions( + response, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.CountTransactions( ctx, - testServer.GetValue(), operations.V2CountTransactionsRequest{ Ledger: "default", RequestBody: map[string]interface{}{ @@ -637,26 +613,24 @@ var _ = Context("Ledger transactions list API tests", func() { }, ) Expect(err).ToNot(HaveOccurred()) - Expect(response).To(Equal(0)) + Expect(response.Headers["Count"]).To(Equal([]string{"0"})) }) - It("should be listed on api", func() { - response, err := ListTransactions( + It("should be listed on api", func(specContext SpecContext) { + response, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.ListTransactions( ctx, - testServer.GetValue(), operations.V2ListTransactionsRequest{ Ledger: "default", Expand: pointer.For("volumes,effectiveVolumes"), }, ) Expect(err).ToNot(HaveOccurred()) - Expect(response.Data).To(HaveLen(3)) - Expect(response.Data[0]).Should(Equal(*t3)) - Expect(response.Data[1]).Should(Equal(*t2)) - Expect(response.Data[2]).Should(Equal(*t1)) + Expect(response.V2TransactionsCursorResponse.Cursor.Data).To(HaveLen(3)) + Expect(response.V2TransactionsCursorResponse.Cursor.Data[0]).Should(Equal(t3.V2CreateTransactionResponse.Data)) + Expect(response.V2TransactionsCursorResponse.Cursor.Data[1]).Should(Equal(t2.V2CreateTransactionResponse.Data)) + Expect(response.V2TransactionsCursorResponse.Cursor.Data[2]).Should(Equal(t1.V2CreateTransactionResponse.Data)) - response, err = ListTransactions( + response, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.ListTransactions( ctx, - testServer.GetValue(), operations.V2ListTransactionsRequest{ Ledger: "default", Expand: pointer.For("volumes,effectiveVolumes"), @@ -668,14 +642,13 @@ var _ = Context("Ledger transactions list API tests", func() { }, ) Expect(err).ToNot(HaveOccurred()) - Expect(response.Data).To(HaveLen(3)) - Expect(response.Data[0]).Should(Equal(*t3)) - Expect(response.Data[1]).Should(Equal(*t2)) - Expect(response.Data[2]).Should(Equal(*t1)) + Expect(response.V2TransactionsCursorResponse.Cursor.Data).To(HaveLen(3)) + Expect(response.V2TransactionsCursorResponse.Cursor.Data[0]).Should(Equal(t3.V2CreateTransactionResponse.Data)) + Expect(response.V2TransactionsCursorResponse.Cursor.Data[1]).Should(Equal(t2.V2CreateTransactionResponse.Data)) + Expect(response.V2TransactionsCursorResponse.Cursor.Data[2]).Should(Equal(t1.V2CreateTransactionResponse.Data)) - response, err = ListTransactions( + response, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.ListTransactions( ctx, - testServer.GetValue(), operations.V2ListTransactionsRequest{ Ledger: "default", Expand: pointer.For("volumes,effectiveVolumes"), @@ -687,11 +660,10 @@ var _ = Context("Ledger transactions list API tests", func() { }, ) Expect(err).ToNot(HaveOccurred()) - Expect(response.Data).To(HaveLen(0)) + Expect(response.V2TransactionsCursorResponse.Cursor.Data).To(HaveLen(0)) - response, err = ListTransactions( + response, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.ListTransactions( ctx, - testServer.GetValue(), operations.V2ListTransactionsRequest{ Ledger: "default", Expand: pointer.For("volumes,effectiveVolumes"), @@ -703,14 +675,13 @@ var _ = Context("Ledger transactions list API tests", func() { }, ) Expect(err).ToNot(HaveOccurred()) - Expect(response.Data).To(HaveLen(3)) - Expect(response.Data[0]).Should(Equal(*t3)) - Expect(response.Data[1]).Should(Equal(*t2)) - Expect(response.Data[2]).Should(Equal(*t1)) + Expect(response.V2TransactionsCursorResponse.Cursor.Data).To(HaveLen(3)) + Expect(response.V2TransactionsCursorResponse.Cursor.Data[0]).Should(Equal(t3.V2CreateTransactionResponse.Data)) + Expect(response.V2TransactionsCursorResponse.Cursor.Data[1]).Should(Equal(t2.V2CreateTransactionResponse.Data)) + Expect(response.V2TransactionsCursorResponse.Cursor.Data[2]).Should(Equal(t1.V2CreateTransactionResponse.Data)) - response, err = ListTransactions( + response, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.ListTransactions( ctx, - testServer.GetValue(), operations.V2ListTransactionsRequest{ Ledger: "default", Expand: pointer.For("volumes,effectiveVolumes"), @@ -722,11 +693,10 @@ var _ = Context("Ledger transactions list API tests", func() { }, ) Expect(err).ToNot(HaveOccurred()) - Expect(response.Data).To(HaveLen(0)) + Expect(response.V2TransactionsCursorResponse.Cursor.Data).To(HaveLen(0)) - response, err = ListTransactions( + response, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.ListTransactions( ctx, - testServer.GetValue(), operations.V2ListTransactionsRequest{ Ledger: "default", Expand: pointer.For("volumes,effectiveVolumes"), @@ -738,11 +708,10 @@ var _ = Context("Ledger transactions list API tests", func() { }, ) Expect(err).ToNot(HaveOccurred()) - Expect(response.Data).To(HaveLen(0)) + Expect(response.V2TransactionsCursorResponse.Cursor.Data).To(HaveLen(0)) - response, err = ListTransactions( + response, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.ListTransactions( ctx, - testServer.GetValue(), operations.V2ListTransactionsRequest{ Ledger: "default", Expand: pointer.For("volumes,effectiveVolumes"), @@ -754,14 +723,13 @@ var _ = Context("Ledger transactions list API tests", func() { }, ) Expect(err).ToNot(HaveOccurred()) - Expect(response.Data).To(HaveLen(3)) - Expect(response.Data[0]).Should(Equal(*t3)) - Expect(response.Data[1]).Should(Equal(*t2)) - Expect(response.Data[2]).Should(Equal(*t1)) + Expect(response.V2TransactionsCursorResponse.Cursor.Data).To(HaveLen(3)) + Expect(response.V2TransactionsCursorResponse.Cursor.Data[0]).Should(Equal(t3.V2CreateTransactionResponse.Data)) + Expect(response.V2TransactionsCursorResponse.Cursor.Data[1]).Should(Equal(t2.V2CreateTransactionResponse.Data)) + Expect(response.V2TransactionsCursorResponse.Cursor.Data[2]).Should(Equal(t1.V2CreateTransactionResponse.Data)) - response, err = ListTransactions( + response, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.ListTransactions( ctx, - testServer.GetValue(), operations.V2ListTransactionsRequest{ Ledger: "default", RequestBody: map[string]interface{}{ @@ -773,13 +741,12 @@ var _ = Context("Ledger transactions list API tests", func() { }, ) Expect(err).ToNot(HaveOccurred()) - Expect(response.Data).Should(HaveLen(2)) - Expect(response.Data[0]).Should(Equal(*t2)) - Expect(response.Data[1]).Should(Equal(*t1)) + Expect(response.V2TransactionsCursorResponse.Cursor.Data).Should(HaveLen(2)) + Expect(response.V2TransactionsCursorResponse.Cursor.Data[0]).Should(Equal(t2.V2CreateTransactionResponse.Data)) + Expect(response.V2TransactionsCursorResponse.Cursor.Data[1]).Should(Equal(t1.V2CreateTransactionResponse.Data)) - response, err = ListTransactions( + response, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.ListTransactions( ctx, - testServer.GetValue(), operations.V2ListTransactionsRequest{ Ledger: "default", RequestBody: map[string]interface{}{ @@ -791,11 +758,10 @@ var _ = Context("Ledger transactions list API tests", func() { }, ) Expect(err).ToNot(HaveOccurred()) - Expect(response.Data).Should(HaveLen(0)) + Expect(response.V2TransactionsCursorResponse.Cursor.Data).Should(HaveLen(0)) - response, err = ListTransactions( + response, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.ListTransactions( ctx, - testServer.GetValue(), operations.V2ListTransactionsRequest{ Ledger: "default", Expand: pointer.For("volumes,effectiveVolumes"), @@ -807,13 +773,12 @@ var _ = Context("Ledger transactions list API tests", func() { }, ) Expect(err).ToNot(HaveOccurred()) - Expect(response.Data).Should(HaveLen(2)) - Expect(response.Data[0]).Should(Equal(*t3)) - Expect(response.Data[1]).Should(Equal(*t2)) + Expect(response.V2TransactionsCursorResponse.Cursor.Data).Should(HaveLen(2)) + Expect(response.V2TransactionsCursorResponse.Cursor.Data[0]).Should(Equal(t3.V2CreateTransactionResponse.Data)) + Expect(response.V2TransactionsCursorResponse.Cursor.Data[1]).Should(Equal(t2.V2CreateTransactionResponse.Data)) - response, err = ListTransactions( + response, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.ListTransactions( ctx, - testServer.GetValue(), operations.V2ListTransactionsRequest{ Ledger: "default", Expand: pointer.For("volumes,effectiveVolumes"), @@ -825,12 +790,11 @@ var _ = Context("Ledger transactions list API tests", func() { }, ) Expect(err).ToNot(HaveOccurred()) - Expect(response.Data).Should(HaveLen(1)) - Expect(response.Data[0]).Should(Equal(*t3)) + Expect(response.V2TransactionsCursorResponse.Cursor.Data).Should(HaveLen(1)) + Expect(response.V2TransactionsCursorResponse.Cursor.Data[0]).Should(Equal(t3.V2CreateTransactionResponse.Data)) - response, err = ListTransactions( + response, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.ListTransactions( ctx, - testServer.GetValue(), operations.V2ListTransactionsRequest{ Ledger: "default", Expand: pointer.For("volumes,effectiveVolumes"), @@ -842,11 +806,10 @@ var _ = Context("Ledger transactions list API tests", func() { }, ) Expect(err).ToNot(HaveOccurred()) - Expect(response.Data).Should(HaveLen(0)) + Expect(response.V2TransactionsCursorResponse.Cursor.Data).Should(HaveLen(0)) - response, err = ListTransactions( + response, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.ListTransactions( ctx, - testServer.GetValue(), operations.V2ListTransactionsRequest{ Ledger: "default", Expand: pointer.For("volumes,effectiveVolumes"), @@ -858,13 +821,12 @@ var _ = Context("Ledger transactions list API tests", func() { }, ) Expect(err).ToNot(HaveOccurred()) - Expect(response.Data).Should(HaveLen(2)) - Expect(response.Data[0]).Should(Equal(*t2)) - Expect(response.Data[1]).Should(Equal(*t1)) + Expect(response.V2TransactionsCursorResponse.Cursor.Data).Should(HaveLen(2)) + Expect(response.V2TransactionsCursorResponse.Cursor.Data[0]).Should(Equal(t2.V2CreateTransactionResponse.Data)) + Expect(response.V2TransactionsCursorResponse.Cursor.Data[1]).Should(Equal(t1.V2CreateTransactionResponse.Data)) - response, err = ListTransactions( + response, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.ListTransactions( ctx, - testServer.GetValue(), operations.V2ListTransactionsRequest{ Ledger: "default", Expand: pointer.For("volumes,effectiveVolumes"), @@ -876,12 +838,11 @@ var _ = Context("Ledger transactions list API tests", func() { }, ) Expect(err).ToNot(HaveOccurred()) - Expect(response.Data).Should(HaveLen(1)) - Expect(response.Data[0]).Should(Equal(*t1)) + Expect(response.V2TransactionsCursorResponse.Cursor.Data).Should(HaveLen(1)) + Expect(response.V2TransactionsCursorResponse.Cursor.Data[0]).Should(Equal(t1.V2CreateTransactionResponse.Data)) - response, err = ListTransactions( + response, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.ListTransactions( ctx, - testServer.GetValue(), operations.V2ListTransactionsRequest{ Ledger: "default", Expand: pointer.For("volumes,effectiveVolumes"), @@ -893,12 +854,11 @@ var _ = Context("Ledger transactions list API tests", func() { }, ) Expect(err).ToNot(HaveOccurred()) - Expect(response.Data).Should(HaveLen(0)) + Expect(response.V2TransactionsCursorResponse.Cursor.Data).Should(HaveLen(0)) By("using $not operator on account 'world'", func() { - response, err = ListTransactions( + response, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.ListTransactions( ctx, - testServer.GetValue(), operations.V2ListTransactionsRequest{ Ledger: "default", Expand: pointer.For("volumes,effectiveVolumes"), @@ -912,46 +872,42 @@ var _ = Context("Ledger transactions list API tests", func() { }, ) Expect(err).ToNot(HaveOccurred()) - Expect(response.Data).Should(HaveLen(2)) + Expect(response.V2TransactionsCursorResponse.Cursor.Data).Should(HaveLen(2)) }) }) - It("should be gettable on api", func() { - _, err := GetTransaction( + It("should be gettable on api", func(specContext SpecContext) { + _, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.GetTransaction( ctx, - testServer.GetValue(), operations.V2GetTransactionRequest{ Ledger: "default", - ID: t1.ID, + ID: t1.V2CreateTransactionResponse.Data.ID, Expand: pointer.For("volumes,effectiveVolumes"), }, ) Expect(err).ToNot(HaveOccurred()) - _, err = GetTransaction( + _, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.GetTransaction( ctx, - testServer.GetValue(), operations.V2GetTransactionRequest{ Ledger: "default", - ID: t2.ID, + ID: t2.V2CreateTransactionResponse.Data.ID, Expand: pointer.For("volumes,effectiveVolumes"), }, ) Expect(err).ToNot(HaveOccurred()) - _, err = GetTransaction( + _, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.GetTransaction( ctx, - testServer.GetValue(), operations.V2GetTransactionRequest{ Ledger: "default", - ID: t3.ID, + ID: t3.V2CreateTransactionResponse.Data.ID, Expand: pointer.For("volumes,effectiveVolumes"), }, ) Expect(err).ToNot(HaveOccurred()) - _, err = GetTransaction( + _, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.GetTransaction( ctx, - testServer.GetValue(), operations.V2GetTransactionRequest{ Ledger: "default", ID: big.NewInt(666), @@ -963,27 +919,25 @@ var _ = Context("Ledger transactions list API tests", func() { }) When("counting and listing transactions empty", func() { - It("should be countable on api even if empty", func() { - response, err := CountTransactions( + It("should be countable on api even if empty", func(specContext SpecContext) { + response, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.CountTransactions( ctx, - testServer.GetValue(), operations.V2CountTransactionsRequest{ Ledger: "default", }, ) Expect(err).ToNot(HaveOccurred()) - Expect(response).To(Equal(0)) + Expect(response.Headers["Count"]).To(Equal([]string{"0"})) }) - It("should be listed on api even if empty", func() { - response, err := ListTransactions( + It("should be listed on api even if empty", func(specContext SpecContext) { + response, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.ListTransactions( ctx, - testServer.GetValue(), operations.V2ListTransactionsRequest{ Ledger: "default", }, ) Expect(err).ToNot(HaveOccurred()) - Expect(response.Data).To(HaveLen(0)) + Expect(response.V2TransactionsCursorResponse.Cursor.Data).To(HaveLen(0)) }) }) }) diff --git a/test/e2e/api_transactions_metadata_test.go b/test/e2e/api_transactions_metadata_test.go index ca90aa677f..80d1326b52 100644 --- a/test/e2e/api_transactions_metadata_test.go +++ b/test/e2e/api_transactions_metadata_test.go @@ -5,12 +5,13 @@ package test_suite import ( "github.com/formancehq/go-libs/v2/logging" . "github.com/formancehq/go-libs/v2/testing/api" - "github.com/formancehq/go-libs/v2/testing/deferred" + . "github.com/formancehq/go-libs/v2/testing/deferred/ginkgo" "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" "github.com/formancehq/go-libs/v2/testing/testservice" "github.com/formancehq/ledger/pkg/client/models/components" "github.com/formancehq/ledger/pkg/client/models/operations" . "github.com/formancehq/ledger/pkg/testserver" + "github.com/formancehq/ledger/pkg/testserver/ginkgo" "math/big" "time" @@ -24,8 +25,8 @@ var _ = Context("Ledger accounts list API tests", func() { ctx = logging.TestingContext() ) - testServer := DeferTestServer( - deferred.DeferMap(db, (*pgtesting.Database).ConnectionOptions), + testServer := ginkgo.DeferTestServer( + DeferMap(db, (*pgtesting.Database).ConnectionOptions), testservice.WithInstruments( testservice.DebugInstrumentation(debug), testservice.OutputInstrumentation(GinkgoWriter), @@ -33,8 +34,8 @@ var _ = Context("Ledger accounts list API tests", func() { testservice.WithLogger(GinkgoT()), ) - BeforeEach(func() { - err := CreateLedger(ctx, testServer.GetValue(), operations.V2CreateLedgerRequest{ + BeforeEach(func(specContext SpecContext) { + _, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.CreateLedger(ctx, operations.V2CreateLedgerRequest{ Ledger: "default", }) Expect(err).To(BeNil()) @@ -42,14 +43,13 @@ var _ = Context("Ledger accounts list API tests", func() { When("creating a transaction on a ledger", func() { var ( timestamp = time.Now().Round(time.Second).UTC() - rsp *components.V2Transaction + rsp *operations.V2CreateTransactionResponse err error ) - BeforeEach(func() { + BeforeEach(func(specContext SpecContext) { // Create a transaction - rsp, err = CreateTransaction( + rsp, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.CreateTransaction( ctx, - testServer.GetValue(), operations.V2CreateTransactionRequest{ V2PostTransaction: components.V2PostTransaction{ Metadata: map[string]string{}, @@ -69,24 +69,22 @@ var _ = Context("Ledger accounts list API tests", func() { Expect(err).ToNot(HaveOccurred()) // Check existence on api - _, err := GetTransaction( + _, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.GetTransaction( ctx, - testServer.GetValue(), operations.V2GetTransactionRequest{ Ledger: "default", - ID: rsp.ID, + ID: rsp.V2CreateTransactionResponse.Data.ID, }, ) Expect(err).ToNot(HaveOccurred()) }) - It("should fail if the transaction does not exist", func() { + It("should fail if the transaction does not exist", func(specContext SpecContext) { metadata := map[string]string{ "foo": "bar", } - err := AddMetadataToTransaction( + _, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.AddMetadataOnTransaction( ctx, - testServer.GetValue(), operations.V2AddMetadataOnTransactionRequest{ RequestBody: metadata, Ledger: "default", @@ -100,29 +98,27 @@ var _ = Context("Ledger accounts list API tests", func() { metadata := map[string]string{ "foo": "bar", } - BeforeEach(func() { - err := AddMetadataToTransaction( + BeforeEach(func(specContext SpecContext) { + _, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.AddMetadataOnTransaction( ctx, - testServer.GetValue(), operations.V2AddMetadataOnTransactionRequest{ RequestBody: metadata, Ledger: "default", - ID: rsp.ID, + ID: rsp.V2CreateTransactionResponse.Data.ID, }, ) Expect(err).To(Succeed()) }) - It("should be available on api", func() { - response, err := GetTransaction( + It("should be available on api", func(specContext SpecContext) { + response, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.GetTransaction( ctx, - testServer.GetValue(), operations.V2GetTransactionRequest{ Ledger: "default", - ID: rsp.ID, + ID: rsp.V2CreateTransactionResponse.Data.ID, }, ) Expect(err).ToNot(HaveOccurred()) - Expect(response.Metadata).Should(Equal(metadata)) + Expect(response.V2GetTransactionResponse.Data.Metadata).Should(Equal(metadata)) }) }) }) diff --git a/test/e2e/api_transactions_revert_test.go b/test/e2e/api_transactions_revert_test.go index f616be4ffb..25086faf35 100644 --- a/test/e2e/api_transactions_revert_test.go +++ b/test/e2e/api_transactions_revert_test.go @@ -3,10 +3,12 @@ package test_suite import ( - "github.com/formancehq/go-libs/v2/testing/deferred" + "github.com/formancehq/go-libs/v2/testing/deferred/ginkgo" + . "github.com/formancehq/go-libs/v2/testing/deferred/ginkgo" "github.com/formancehq/go-libs/v2/testing/platform/natstesting" "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" "github.com/formancehq/go-libs/v2/testing/testservice" + . "github.com/formancehq/ledger/pkg/testserver/ginkgo" "math/big" "time" @@ -26,13 +28,13 @@ import ( var _ = Context("Ledger revert transactions API tests", func() { var ( - db = UseTemplatedDatabase() - ctx = logging.TestingContext() - natsURL = deferred.DeferMap(natsServer, (*natstesting.NatsServer).ClientURL) + db = UseTemplatedDatabase() + ctx = logging.TestingContext() + natsURL = ginkgo.DeferMap(natsServer, (*natstesting.NatsServer).ClientURL) ) testServer := DeferTestServer( - deferred.DeferMap(db, (*pgtesting.Database).ConnectionOptions), + ginkgo.DeferMap(db, (*pgtesting.Database).ConnectionOptions), testservice.WithInstruments( testservice.NatsInstrumentation(natsURL), testservice.DebugInstrumentation(debug), @@ -41,8 +43,8 @@ var _ = Context("Ledger revert transactions API tests", func() { testservice.WithLogger(GinkgoT()), ) - BeforeEach(func() { - err := CreateLedger(ctx, testServer.GetValue(), operations.V2CreateLedgerRequest{ + BeforeEach(func(specContext SpecContext) { + _, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.CreateLedger(ctx, operations.V2CreateLedgerRequest{ Ledger: "default", }) Expect(err).To(BeNil()) @@ -50,15 +52,14 @@ var _ = Context("Ledger revert transactions API tests", func() { When("creating a transaction on a ledger", func() { var ( timestamp = time.Now().Round(time.Second).UTC() - tx *components.V2Transaction + tx *operations.V2CreateTransactionResponse events chan *nats.Msg err error ) - BeforeEach(func() { - _, events = Subscribe(GinkgoT(), testServer.GetValue(), natsURL) - tx, err = CreateTransaction( + BeforeEach(func(specContext SpecContext) { + _, events = Subscribe(specContext, testServer, natsURL) + tx, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.CreateTransaction( ctx, - testServer.GetValue(), operations.V2CreateTransactionRequest{ V2PostTransaction: components.V2PostTransaction{ Metadata: map[string]string{}, @@ -78,10 +79,9 @@ var _ = Context("Ledger revert transactions API tests", func() { Expect(err).ToNot(HaveOccurred()) }) When("transferring funds from destination to another account", func() { - BeforeEach(func() { - _, err := CreateTransaction( + BeforeEach(func(specContext SpecContext) { + _, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.CreateTransaction( ctx, - testServer.GetValue(), operations.V2CreateTransactionRequest{ V2PostTransaction: components.V2PostTransaction{ Metadata: map[string]string{}, @@ -105,13 +105,12 @@ var _ = Context("Ledger revert transactions API tests", func() { force bool err error ) - revertTx := func() { - _, err = RevertTransaction( + revertTx := func(specContext SpecContext) { + _, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.RevertTransaction( ctx, - testServer.GetValue(), operations.V2RevertTransactionRequest{ Force: pointer.For(force), - ID: tx.ID, + ID: tx.V2CreateTransactionResponse.Data.ID, Ledger: "default", }, ) @@ -132,13 +131,12 @@ var _ = Context("Ledger revert transactions API tests", func() { }) }) When("reverting it", func() { - BeforeEach(func() { - _, err := RevertTransaction( + BeforeEach(func(specContext SpecContext) { + _, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.RevertTransaction( ctx, - testServer.GetValue(), operations.V2RevertTransactionRequest{ Ledger: "default", - ID: tx.ID, + ID: tx.V2CreateTransactionResponse.Data.ID, }, ) Expect(err).To(Succeed()) @@ -146,27 +144,25 @@ var _ = Context("Ledger revert transactions API tests", func() { It("should trigger a new event", func() { Eventually(events).Should(Receive(Event(ledgerevents.EventTypeRevertedTransaction))) }) - It("should revert the original transaction", func() { - response, err := GetTransaction( + It("should revert the original transaction", func(specContext SpecContext) { + response, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.GetTransaction( ctx, - testServer.GetValue(), operations.V2GetTransactionRequest{ Ledger: "default", - ID: tx.ID, + ID: tx.V2CreateTransactionResponse.Data.ID, }, ) Expect(err).NotTo(HaveOccurred()) - Expect(response.Reverted).To(BeTrue()) + Expect(response.V2GetTransactionResponse.Data.Reverted).To(BeTrue()) }) When("trying to revert again", func() { - It("should be rejected", func() { - _, err := RevertTransaction( + It("should be rejected", func(specContext SpecContext) { + _, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.RevertTransaction( ctx, - testServer.GetValue(), operations.V2RevertTransactionRequest{ Ledger: "default", - ID: tx.ID, + ID: tx.V2CreateTransactionResponse.Data.ID, }, ) Expect(err).NotTo(BeNil()) @@ -175,66 +171,62 @@ var _ = Context("Ledger revert transactions API tests", func() { }) }) When("reverting it at effective date", func() { - BeforeEach(func() { - _, err := RevertTransaction( + BeforeEach(func(specContext SpecContext) { + _, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.RevertTransaction( ctx, - testServer.GetValue(), operations.V2RevertTransactionRequest{ Ledger: "default", - ID: tx.ID, + ID: tx.V2CreateTransactionResponse.Data.ID, AtEffectiveDate: pointer.For(true), }, ) Expect(err).To(Succeed()) }) - It("should revert the original transaction at date of the original tx", func() { - response, err := GetTransaction( + It("should revert the original transaction at date of the original tx", func(specContext SpecContext) { + response, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.GetTransaction( ctx, - testServer.GetValue(), operations.V2GetTransactionRequest{ Ledger: "default", - ID: tx.ID, + ID: tx.V2CreateTransactionResponse.Data.ID, }, ) Expect(err).NotTo(HaveOccurred()) - Expect(response.Reverted).To(BeTrue()) - Expect(response.Timestamp).To(Equal(tx.Timestamp)) + Expect(response.V2GetTransactionResponse.Data.Reverted).To(BeTrue()) + Expect(response.V2GetTransactionResponse.Data.Timestamp).To(Equal(tx.V2CreateTransactionResponse.Data.Timestamp)) }) }) When("reverting with dryRun", func() { - BeforeEach(func() { - _, err := RevertTransaction( + BeforeEach(func(specContext SpecContext) { + _, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.RevertTransaction( ctx, - testServer.GetValue(), operations.V2RevertTransactionRequest{ Ledger: "default", - ID: tx.ID, + ID: tx.V2CreateTransactionResponse.Data.ID, DryRun: pointer.For(true), }, ) Expect(err).To(Succeed()) }) - It("should not revert the transaction", func() { - tx, err := GetTransaction(ctx, testServer.GetValue(), operations.V2GetTransactionRequest{ + It("should not revert the transaction", func(specContext SpecContext) { + tx, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.GetTransaction(ctx, operations.V2GetTransactionRequest{ Ledger: "default", - ID: tx.ID, + ID: tx.V2CreateTransactionResponse.Data.ID, }) Expect(err).To(BeNil()) - Expect(tx.Reverted).To(BeFalse()) + Expect(tx.V2GetTransactionResponse.Data.Reverted).To(BeFalse()) }) }) }) When("creating a transaction through an empty passthrough account", func() { var ( timestamp = time.Now().Round(time.Second).UTC() - tx *components.V2Transaction + tx *operations.V2CreateTransactionResponse err error ) - BeforeEach(func() { - tx, err = CreateTransaction( + BeforeEach(func(specContext SpecContext) { + tx, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.CreateTransaction( ctx, - testServer.GetValue(), operations.V2CreateTransactionRequest{ V2PostTransaction: components.V2PostTransaction{ Metadata: map[string]string{}, @@ -254,10 +246,9 @@ var _ = Context("Ledger revert transactions API tests", func() { Expect(err).ToNot(HaveOccurred()) }) When("creating the pass-through transaction", func() { - BeforeEach(func() { - tx, err = CreateTransaction( + BeforeEach(func(specContext SpecContext) { + tx, err = Wait(specContext, DeferClient(testServer)).Ledger.V2.CreateTransaction( ctx, - testServer.GetValue(), operations.V2CreateTransactionRequest{ V2PostTransaction: components.V2PostTransaction{ Metadata: map[string]string{}, @@ -283,30 +274,28 @@ var _ = Context("Ledger revert transactions API tests", func() { Expect(err).ToNot(HaveOccurred()) }) When("reverting the pass-through transaction", func() { - BeforeEach(func() { - _, err := RevertTransaction( + BeforeEach(func(specContext SpecContext) { + _, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.RevertTransaction( ctx, - testServer.GetValue(), operations.V2RevertTransactionRequest{ Ledger: "default", - ID: tx.ID, + ID: tx.V2CreateTransactionResponse.Data.ID, AtEffectiveDate: pointer.For(true), }, ) Expect(err).To(Succeed()) }) - It("should revert the passthrough transaction at date of the original tx", func() { - response, err := GetTransaction( + It("should revert the passthrough transaction at date of the original tx", func(specContext SpecContext) { + response, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.GetTransaction( ctx, - testServer.GetValue(), operations.V2GetTransactionRequest{ Ledger: "default", - ID: tx.ID, + ID: tx.V2CreateTransactionResponse.Data.ID, }, ) Expect(err).NotTo(HaveOccurred()) - Expect(response.Reverted).To(BeTrue()) - Expect(response.Timestamp).To(Equal(tx.Timestamp)) + Expect(response.V2GetTransactionResponse.Data.Reverted).To(BeTrue()) + Expect(response.V2GetTransactionResponse.Data.Timestamp).To(Equal(tx.V2CreateTransactionResponse.Data.Timestamp)) }) }) }) diff --git a/test/e2e/api_volumes_test.go b/test/e2e/api_volumes_test.go index e6638376ff..779c1bd516 100644 --- a/test/e2e/api_volumes_test.go +++ b/test/e2e/api_volumes_test.go @@ -5,12 +5,13 @@ package test_suite import ( "github.com/formancehq/go-libs/v2/logging" "github.com/formancehq/go-libs/v2/pointer" - "github.com/formancehq/go-libs/v2/testing/deferred" + . "github.com/formancehq/go-libs/v2/testing/deferred/ginkgo" "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" "github.com/formancehq/go-libs/v2/testing/testservice" "github.com/formancehq/ledger/pkg/client/models/components" "github.com/formancehq/ledger/pkg/client/models/operations" . "github.com/formancehq/ledger/pkg/testserver" + . "github.com/formancehq/ledger/pkg/testserver/ginkgo" "math/big" "time" @@ -35,7 +36,7 @@ var _ = Context("Ledger accounts list API tests", func() { ) testServer := DeferTestServer( - deferred.DeferMap(db, (*pgtesting.Database).ConnectionOptions), + DeferMap(db, (*pgtesting.Database).ConnectionOptions), testservice.WithInstruments( testservice.DebugInstrumentation(debug), testservice.OutputInstrumentation(GinkgoWriter), @@ -53,16 +54,15 @@ var _ = Context("Ledger accounts list API tests", func() { {Amount: 150, Asset: "USD", Source: "account:user1", Destination: "bank", EffectiveDate: now.Add(2 * time.Hour)}, //user1:150, user2:50, world:-400, bank:200 } - BeforeEach(func() { - err := CreateLedger(ctx, testServer.GetValue(), operations.V2CreateLedgerRequest{ + BeforeEach(func(specContext SpecContext) { + _, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.CreateLedger(ctx, operations.V2CreateLedgerRequest{ Ledger: "default", }) Expect(err).To(BeNil()) for _, transaction := range transactions { - _, err := CreateTransaction( + _, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.CreateTransaction( ctx, - testServer.GetValue(), operations.V2CreateTransactionRequest{ V2PostTransaction: components.V2PostTransaction{ Metadata: map[string]string{}, @@ -84,10 +84,9 @@ var _ = Context("Ledger accounts list API tests", func() { }) When("Get current Volumes and Balances From origin of time till now (insertion-date)", func() { - It("should be ok", func() { - response, err := GetVolumesWithBalances( + It("should be ok", func(specContext SpecContext) { + response, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.GetVolumesWithBalances( ctx, - testServer.GetValue(), operations.V2GetVolumesWithBalancesRequest{ InsertionDate: pointer.For(true), Ledger: "default", @@ -95,8 +94,8 @@ var _ = Context("Ledger accounts list API tests", func() { ) Expect(err).ToNot(HaveOccurred()) - Expect(len(response.Data)).To(Equal(4)) - for _, volume := range response.Data { + Expect(len(response.V2VolumesWithBalanceCursorResponse.Cursor.Data)).To(Equal(4)) + for _, volume := range response.V2VolumesWithBalanceCursorResponse.Cursor.Data { if volume.Account == "account:user1" { Expect(volume.Balance).To(Equal(big.NewInt(150))) } @@ -114,11 +113,10 @@ var _ = Context("Ledger accounts list API tests", func() { }) When("Get Volumes and Balances From oot til oot+2 hours (effectiveDate) ", func() { - It("should be ok", func() { + It("should be ok", func(specContext SpecContext) { - response, err := GetVolumesWithBalances( + response, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.GetVolumesWithBalances( ctx, - testServer.GetValue(), operations.V2GetVolumesWithBalancesRequest{ StartTime: pointer.For(now.Add(-4 * time.Hour)), EndTime: pointer.For(now.Add(-2 * time.Hour)), @@ -127,8 +125,8 @@ var _ = Context("Ledger accounts list API tests", func() { ) Expect(err).ToNot(HaveOccurred()) - Expect(len(response.Data)).To(Equal(3)) - for _, volume := range response.Data { + Expect(len(response.V2VolumesWithBalanceCursorResponse.Cursor.Data)).To(Equal(3)) + for _, volume := range response.V2VolumesWithBalanceCursorResponse.Cursor.Data { if volume.Account == "account:user1" { Expect(volume.Balance).To(Equal(big.NewInt(25))) } @@ -143,10 +141,9 @@ var _ = Context("Ledger accounts list API tests", func() { }) When("Get Volumes and Balances Filter by address account", func() { - It("should be ok", func() { - response, err := GetVolumesWithBalances( + It("should be ok", func(specContext SpecContext) { + response, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.GetVolumesWithBalances( ctx, - testServer.GetValue(), operations.V2GetVolumesWithBalancesRequest{ InsertionDate: pointer.For(true), RequestBody: map[string]interface{}{ @@ -158,8 +155,8 @@ var _ = Context("Ledger accounts list API tests", func() { }, ) Expect(err).ToNot(HaveOccurred()) - Expect(response.Data).To(HaveLen(2)) - for _, volume := range response.Data { + Expect(response.V2VolumesWithBalanceCursorResponse.Cursor.Data).To(HaveLen(2)) + for _, volume := range response.V2VolumesWithBalanceCursorResponse.Cursor.Data { if volume.Account == "account:user1" { Expect(volume.Balance).To(Equal(big.NewInt(150))) } @@ -171,10 +168,9 @@ var _ = Context("Ledger accounts list API tests", func() { }) When("Get Volumes and Balances Filter by address account a,d and end-time now effective", func() { - It("should be ok", func() { - response, err := GetVolumesWithBalances( + It("should be ok", func(specContext SpecContext) { + response, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.GetVolumesWithBalances( ctx, - testServer.GetValue(), operations.V2GetVolumesWithBalancesRequest{ RequestBody: map[string]interface{}{ "$match": map[string]any{ @@ -186,9 +182,9 @@ var _ = Context("Ledger accounts list API tests", func() { }, ) Expect(err).ToNot(HaveOccurred()) - Expect(response.Data).To(HaveLen(2)) + Expect(response.V2VolumesWithBalanceCursorResponse.Cursor.Data).To(HaveLen(2)) - for _, volume := range response.Data { + for _, volume := range response.V2VolumesWithBalanceCursorResponse.Cursor.Data { if volume.Account == "account:user1" { Expect(volume.Balance).To(Equal(big.NewInt(200))) } @@ -200,10 +196,9 @@ var _ = Context("Ledger accounts list API tests", func() { }) When("Get Volumes and Balances Filter by address account which doesn't exist", func() { - It("should be ok", func() { - response, err := GetVolumesWithBalances( + It("should be ok", func(specContext SpecContext) { + response, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.GetVolumesWithBalances( ctx, - testServer.GetValue(), operations.V2GetVolumesWithBalancesRequest{ RequestBody: map[string]interface{}{ "$match": map[string]any{ @@ -214,15 +209,14 @@ var _ = Context("Ledger accounts list API tests", func() { }, ) Expect(err).ToNot(HaveOccurred()) - Expect(response.Data).To(HaveLen(0)) + Expect(response.V2VolumesWithBalanceCursorResponse.Cursor.Data).To(HaveLen(0)) }) }) When("Get Volumes and Balances Filter With futures dates empty", func() { - It("should be ok", func() { - response, err := GetVolumesWithBalances( + It("should be ok", func(specContext SpecContext) { + response, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.GetVolumesWithBalances( ctx, - testServer.GetValue(), operations.V2GetVolumesWithBalancesRequest{ StartTime: pointer.For(time.Now().Add(8 * time.Hour)), EndTime: pointer.For(time.Now().Add(12 * time.Hour)), @@ -230,15 +224,14 @@ var _ = Context("Ledger accounts list API tests", func() { }, ) Expect(err).ToNot(HaveOccurred()) - Expect(len(response.Data)).To(Equal(0)) + Expect(len(response.V2VolumesWithBalanceCursorResponse.Cursor.Data)).To(Equal(0)) }) }) When("Get Volumes and Balances Filter by address account aggregation by level 1", func() { - It("should be ok", func() { - response, err := GetVolumesWithBalances( + It("should be ok", func(specContext SpecContext) { + response, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.GetVolumesWithBalances( ctx, - testServer.GetValue(), operations.V2GetVolumesWithBalancesRequest{ InsertionDate: pointer.For(true), RequestBody: map[string]interface{}{ @@ -251,8 +244,8 @@ var _ = Context("Ledger accounts list API tests", func() { }, ) Expect(err).ToNot(HaveOccurred()) - Expect(len(response.Data)).To(Equal(1)) - for _, volume := range response.Data { + Expect(len(response.V2VolumesWithBalanceCursorResponse.Cursor.Data)).To(Equal(1)) + for _, volume := range response.V2VolumesWithBalanceCursorResponse.Cursor.Data { if volume.Account == "account" { Expect(volume.Balance).To(Equal(big.NewInt(200))) } diff --git a/test/e2e/app_lifecycle_test.go b/test/e2e/app_lifecycle_test.go index 287316a962..93523bbc6a 100644 --- a/test/e2e/app_lifecycle_test.go +++ b/test/e2e/app_lifecycle_test.go @@ -9,7 +9,7 @@ import ( "github.com/formancehq/go-libs/v2/bun/bunconnect" "github.com/formancehq/go-libs/v2/logging" "github.com/formancehq/go-libs/v2/pointer" - "github.com/formancehq/go-libs/v2/testing/deferred" + . "github.com/formancehq/go-libs/v2/testing/deferred/ginkgo" "github.com/formancehq/go-libs/v2/testing/platform/natstesting" "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" "github.com/formancehq/go-libs/v2/testing/testservice" @@ -22,6 +22,7 @@ import ( "github.com/formancehq/ledger/pkg/client/models/operations" ledgerevents "github.com/formancehq/ledger/pkg/events" . "github.com/formancehq/ledger/pkg/testserver" + . "github.com/formancehq/ledger/pkg/testserver/ginkgo" "github.com/google/uuid" "github.com/nats-io/nats.go" . "github.com/onsi/ginkgo/v2" @@ -38,13 +39,13 @@ var _ = Context("Ledger application lifecycle tests", func() { Context("Pending transaction should be fully processed before stopping or restarting the server", func() { db := UseTemplatedDatabase() - connectionOptions := deferred.DeferMap(db, func(from *pgtesting.Database) bunconnect.ConnectionOptions { + connectionOptions := DeferMap(db, func(from *pgtesting.Database) bunconnect.ConnectionOptions { return bunconnect.ConnectionOptions{ DatabaseSourceName: from.ConnectionOptions().DatabaseSourceName, MaxOpenConns: 100, } }) - natsURL := deferred.DeferMap(natsServer, (*natstesting.NatsServer).ClientURL) + natsURL := DeferMap(natsServer, (*natstesting.NatsServer).ClientURL) testServer := DeferTestServer( connectionOptions, testservice.WithInstruments( @@ -56,20 +57,26 @@ var _ = Context("Ledger application lifecycle tests", func() { ) var events chan *nats.Msg - BeforeEach(func() { - _, events = Subscribe(GinkgoT(), testServer.GetValue(), natsURL) + BeforeEach(func(specContext SpecContext) { + _, events = Subscribe(specContext, testServer, natsURL) }) When("starting the service", func() { - It("should be ok", func() { - info, err := Client(testServer.GetValue()).Ledger.GetInfo(ctx) + It("should be ok", func(specContext SpecContext) { + testServer, err := testServer.Wait(specContext) + Expect(err).To(BeNil()) + + info, err := Client(testServer).Ledger.GetInfo(ctx) Expect(err).NotTo(HaveOccurred()) Expect(info.V2ConfigInfoResponse.Version).To(Equal("develop")) }) }) When("restarting the service", func() { BeforeEach(func(ctx context.Context) { - Expect(testServer.GetValue().Restart(ctx)).To(BeNil()) + testServer, err := testServer.Wait(ctx) + Expect(err).To(BeNil()) + + Expect(testServer.Restart(ctx)).To(BeNil()) }) It("should be ok", func() {}) }) @@ -79,8 +86,8 @@ var _ = Context("Ledger application lifecycle tests", func() { countTransactions = 60 serverRestartTimeout = 10 * time.Second ) - BeforeEach(func() { - err := CreateLedger(ctx, testServer.GetValue(), operations.V2CreateLedgerRequest{ + BeforeEach(func(specContext SpecContext) { + _, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.CreateLedger(ctx, operations.V2CreateLedgerRequest{ Ledger: "foo", }) Expect(err).ToNot(HaveOccurred()) @@ -88,7 +95,7 @@ var _ = Context("Ledger application lifecycle tests", func() { // lock logs table to block transactions creation requests // the first tx will block on the log insertion // the next transaction will block earlier on advisory lock acquirement for accounts - db := ConnectToDatabase(ctx, GinkgoT(), connectionOptions) + db := ConnectToDatabase(ctx, connectionOptions) sqlTx, err = db.BeginTx(ctx, &sql.TxOptions{}) Expect(err).To(BeNil()) DeferCleanup(func() { @@ -103,7 +110,7 @@ var _ = Context("Ledger application lifecycle tests", func() { go func() { defer GinkgoRecover() - _, err := CreateTransaction(ctx, testServer.GetValue(), operations.V2CreateTransactionRequest{ + _, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.CreateTransaction(ctx, operations.V2CreateTransactionRequest{ Ledger: "foo", V2PostTransaction: components.V2PostTransaction{ Postings: []components.V2Posting{{ @@ -131,11 +138,11 @@ var _ = Context("Ledger application lifecycle tests", func() { WithTimeout(10 * time.Second). // Once all the transactions are in pending state, we should have one lock // for the first tx, trying to write a new log. - // And, we should also have countTransactions-1 pending lock for the 'bank' account + // And, we should also have CountTransactions-1 pending lock for the 'bank' account Should(BeNumerically("==", countTransactions-1)) // -1 for the first one }) When("restarting the service", func() { - BeforeEach(func() { + BeforeEach(func(specContext SpecContext) { // We will restart the server in a separate goroutine // the server should not restart until all pending transactions creation requests are fully completed restarted := make(chan struct{}) @@ -148,14 +155,17 @@ var _ = Context("Ledger application lifecycle tests", func() { stopContext, cancel := context.WithTimeout(ctx, serverRestartTimeout) DeferCleanup(cancel) - Expect(testServer.GetValue().Stop(stopContext)).To(BeNil()) - Expect(testServer.GetValue().Start(ctx)).To(BeNil()) + testServer, err := testServer.Wait(specContext) + Expect(err).To(BeNil()) + + Expect(testServer.Stop(stopContext)).To(BeNil()) + Expect(testServer.Start(ctx)).To(BeNil()) }) }() // Once the server is restarting, it should not accept any new connection Eventually(func() error { - _, err := GetInfo(ctx, testServer.GetValue()) + _, err := Wait(specContext, DeferClient(testServer)).Ledger.GetInfo(ctx) return err }).ShouldNot(BeNil()) @@ -168,13 +178,13 @@ var _ = Context("Ledger application lifecycle tests", func() { WithTimeout(serverRestartTimeout). Should(BeClosed()) }) - It("in flight transactions should be correctly terminated before", func() { - transactions, err := ListTransactions(ctx, testServer.GetValue(), operations.V2ListTransactionsRequest{ + It("in flight transactions should be correctly terminated before", func(specContext SpecContext) { + transactions, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.ListTransactions(ctx, operations.V2ListTransactionsRequest{ Ledger: "foo", PageSize: pointer.For(int64(countTransactions)), }) Expect(err).To(BeNil()) - Expect(transactions.Data).To(HaveLen(countTransactions)) + Expect(transactions.V2TransactionsCursorResponse.Cursor.Data).To(HaveLen(countTransactions)) By("all events should have been properly sent", func() { for range countTransactions { @@ -208,17 +218,17 @@ var _ = Context("Ledger application lifecycle tests", func() { } }) testServer := DeferTestServer( - deferred.DeferMap(db, (*pgtesting.Database).ConnectionOptions), + DeferMap(db, (*pgtesting.Database).ConnectionOptions), testservice.WithInstruments( - testservice.NatsInstrumentation(deferred.DeferMap(natsServer, (*natstesting.NatsServer).ClientURL)), + testservice.NatsInstrumentation(DeferMap(natsServer, (*natstesting.NatsServer).ClientURL)), testservice.DebugInstrumentation(debug), testservice.OutputInstrumentation(GinkgoWriter), ), ) - It("should be ok", func() { + It("should be ok", func(specContext SpecContext) { By("we should be able to create a new transaction", func() { - _, err := CreateTransaction(ctx, testServer.GetValue(), operations.V2CreateTransactionRequest{ + _, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.CreateTransaction(ctx, operations.V2CreateTransactionRequest{ Ledger: ledgerName, V2PostTransaction: components.V2PostTransaction{ Metadata: map[string]string{}, @@ -235,11 +245,11 @@ var _ = Context("Ledger application lifecycle tests", func() { Expect(err).To(BeNil()) }) By("we should be able to list transactions", func() { - transactions, err := ListTransactions(ctx, testServer.GetValue(), operations.V2ListTransactionsRequest{ + transactions, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.ListTransactions(ctx, operations.V2ListTransactionsRequest{ Ledger: ledgerName, }) Expect(err).To(BeNil()) - Expect(transactions.Data).To(HaveLen(1)) + Expect(transactions.V2TransactionsCursorResponse.Cursor.Data).To(HaveLen(1)) }) }) }) @@ -248,7 +258,7 @@ var _ = Context("Ledger application lifecycle tests", func() { var _ = Context("Ledger downgrade tests", func() { var ( db = UseTemplatedDatabase() - connectionOptions = deferred.DeferMap(db, (*pgtesting.Database).ConnectionOptions) + connectionOptions = DeferMap(db, (*pgtesting.Database).ConnectionOptions) ctx = logging.TestingContext() ) @@ -262,21 +272,21 @@ var _ = Context("Ledger downgrade tests", func() { ) When("inserting new migrations into the database", func() { - BeforeEach(func() { + BeforeEach(func(specContext SpecContext) { ledgerName := uuid.NewString()[:8] - err := CreateLedger(ctx, testServer.GetValue(), operations.V2CreateLedgerRequest{ + _, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.CreateLedger(ctx, operations.V2CreateLedgerRequest{ Ledger: ledgerName, }) Expect(err).To(BeNil()) - info, err := GetLedgerInfo(ctx, testServer.GetValue(), operations.V2GetLedgerInfoRequest{ + info, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.GetLedgerInfo(ctx, operations.V2GetLedgerInfoRequest{ Ledger: ledgerName, }) Expect(err).To(BeNil()) // Insert a fake migration into the database to simulate a downgrade - _, err = ConnectToDatabase(ctx, GinkgoT(), connectionOptions). + _, err = ConnectToDatabase(ctx, connectionOptions). NewInsert(). ModelTableExpr(ledger.DefaultBucket + ".goose_db_version"). Model(&map[string]any{ @@ -287,14 +297,20 @@ var _ = Context("Ledger downgrade tests", func() { Expect(err).To(BeNil()) }) Context("then when restarting the service", func() { - It("Should fail", func() { - Expect(testServer.GetValue().Restart(ctx)).NotTo(BeNil()) + It("Should fail", func(specContext SpecContext) { + testServer, err := testServer.Wait(specContext) + Expect(err).To(BeNil()) + + Expect(testServer.Restart(ctx)).NotTo(BeNil()) }) }) }) - It("should be ok when targeting health check endpoint", func() { - ret, err := http.DefaultClient.Get(testservice.GetServerURL(testServer.GetValue()).String() + "/_healthcheck") + It("should be ok when targeting health check endpoint", func(specContext SpecContext) { + testServer, err := testServer.Wait(specContext) + Expect(err).To(BeNil()) + + ret, err := http.DefaultClient.Get(testservice.GetServerURL(testServer).String() + "/_healthcheck") Expect(err).To(BeNil()) body := make(map[string]interface{}) diff --git a/test/e2e/app_logs_blocks_async_test.go b/test/e2e/app_logs_blocks_async_test.go index 4f2778966c..67556f547e 100644 --- a/test/e2e/app_logs_blocks_async_test.go +++ b/test/e2e/app_logs_blocks_async_test.go @@ -6,13 +6,14 @@ import ( "fmt" "github.com/formancehq/go-libs/v2/logging" "github.com/formancehq/go-libs/v2/pointer" - "github.com/formancehq/go-libs/v2/testing/deferred" + . "github.com/formancehq/go-libs/v2/testing/deferred/ginkgo" "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" "github.com/formancehq/go-libs/v2/testing/testservice" "github.com/formancehq/ledger/pkg/client/models/components" "github.com/formancehq/ledger/pkg/client/models/operations" "github.com/formancehq/ledger/pkg/features" . "github.com/formancehq/ledger/pkg/testserver" + "github.com/formancehq/ledger/pkg/testserver/ginkgo" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "math/big" @@ -22,7 +23,7 @@ import ( var _ = Context("Logs block async hashing", func() { var ( db = UseTemplatedDatabase() - connectionOptions = deferred.DeferMap(db, (*pgtesting.Database).ConnectionOptions) + connectionOptions = DeferMap(db, (*pgtesting.Database).ConnectionOptions) ctx = logging.TestingContext() ) @@ -32,7 +33,7 @@ var _ = Context("Logs block async hashing", func() { txCount = blockSize * nbBlock ) - testServer := DeferTestServer( + testServer := ginkgo.DeferTestServer( connectionOptions, testservice.WithInstruments( testservice.DebugInstrumentation(debug), @@ -42,13 +43,13 @@ var _ = Context("Logs block async hashing", func() { testservice.WithLogger(GinkgoT()), ) - DeferTestWorker(connectionOptions, testservice.WithInstruments( + ginkgo.DeferTestWorker(connectionOptions, testservice.WithInstruments( LogsHashBlockCRONSpecInstrumentation("* * * * * *"), LogsHashBlockMaxSizeInstrumentation(blockSize), )) - JustBeforeEach(func() { - err := CreateLedger(ctx, testServer.GetValue(), operations.V2CreateLedgerRequest{ + JustBeforeEach(func(specContext SpecContext) { + _, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.CreateLedger(ctx, operations.V2CreateLedgerRequest{ Ledger: "default", V2CreateLedgerRequest: components.V2CreateLedgerRequest{ Features: features.MinimalFeatureSet.With(features.FeatureHashLogs, "ASYNC"), @@ -58,7 +59,7 @@ var _ = Context("Logs block async hashing", func() { }) When(fmt.Sprintf("creating %d transactions", txCount), func() { - JustBeforeEach(func() { + JustBeforeEach(func(specContext SpecContext) { requestBody := make([]components.V2BulkElement, 0, txCount) for i := 0; i < txCount; i++ { requestBody = append(requestBody, components.CreateV2BulkElementCreateTransaction( @@ -76,7 +77,7 @@ var _ = Context("Logs block async hashing", func() { )) } - _, err := CreateBulk(ctx, testServer.GetValue(), operations.V2CreateBulkRequest{ + _, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.CreateBulk(ctx, operations.V2CreateBulkRequest{ Ledger: "default", RequestBody: requestBody, Atomic: pointer.For(true), @@ -84,7 +85,7 @@ var _ = Context("Logs block async hashing", func() { Expect(err).To(BeNil()) }) It(fmt.Sprintf("should generate %d blocks", nbBlock), func() { - db := ConnectToDatabase(ctx, GinkgoT(), connectionOptions) + db := ConnectToDatabase(ctx, connectionOptions) Eventually(func(g Gomega) bool { ret := make([]map[string]any, 0) err := db.NewSelect(). diff --git a/test/e2e/suite_test.go b/test/e2e/suite_test.go index 09f6529d26..388c44038a 100644 --- a/test/e2e/suite_test.go +++ b/test/e2e/suite_test.go @@ -8,9 +8,12 @@ import ( "github.com/formancehq/go-libs/v2/bun/bunconnect" "github.com/formancehq/go-libs/v2/testing/deferred" "github.com/formancehq/go-libs/v2/testing/platform/natstesting" + "github.com/formancehq/go-libs/v2/testing/testservice" ledger "github.com/formancehq/ledger/internal" "github.com/formancehq/ledger/internal/storage/bucket" "github.com/formancehq/ledger/internal/storage/system" + "github.com/nats-io/nats.go" + "github.com/uptrace/bun" "os" "testing" @@ -111,3 +114,29 @@ var _ = SynchronizedBeforeSuite(func(specContext SpecContext) []byte { func UseTemplatedDatabase() *deferred.Deferred[*Database] { return UsePostgresDatabase(pgServer, CreateWithTemplate(DBTemplate)) } + +func ConnectToDatabase(ctx context.Context, dbOptions *deferred.Deferred[bunconnect.ConnectionOptions]) *bun.DB { + db, err := bunconnect.OpenSQLDB(ctx, dbOptions.GetValue()) + Expect(err).To(BeNil()) + + DeferCleanup(db.Close) + + return db +} + +func Subscribe(ctx context.Context, d *deferred.Deferred[*testservice.Service], natsURL *deferred.Deferred[string]) (*nats.Subscription, chan *nats.Msg) { + + srv, err := d.Wait(ctx) + Expect(err).To(BeNil()) + + ret := make(chan *nats.Msg) + conn, err := nats.Connect(natsURL.GetValue()) + Expect(err).To(BeNil()) + + subscription, err := conn.Subscribe(srv.GetID(), func(msg *nats.Msg) { + ret <- msg + }) + Expect(err).To(BeNil()) + + return subscription, ret +} diff --git a/test/e2e/v1_api_balances_test.go b/test/e2e/v1_api_balances_test.go index 17dffc5de1..20b7652389 100644 --- a/test/e2e/v1_api_balances_test.go +++ b/test/e2e/v1_api_balances_test.go @@ -6,12 +6,13 @@ import ( "fmt" "github.com/formancehq/go-libs/v2/logging" "github.com/formancehq/go-libs/v2/pointer" - "github.com/formancehq/go-libs/v2/testing/deferred" + . "github.com/formancehq/go-libs/v2/testing/deferred/ginkgo" "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" "github.com/formancehq/go-libs/v2/testing/testservice" "github.com/formancehq/ledger/pkg/client/models/components" "github.com/formancehq/ledger/pkg/client/models/operations" . "github.com/formancehq/ledger/pkg/testserver" + "github.com/formancehq/ledger/pkg/testserver/ginkgo" "math/big" "time" @@ -25,16 +26,16 @@ var _ = Context("Ledger accounts list API tests", func() { ctx = logging.TestingContext() ) - testServer := DeferTestServer( - deferred.DeferMap(db, (*pgtesting.Database).ConnectionOptions), + testServer := ginkgo.DeferTestServer( + DeferMap(db, (*pgtesting.Database).ConnectionOptions), testservice.WithInstruments( testservice.DebugInstrumentation(debug), testservice.OutputInstrumentation(GinkgoWriter), ), testservice.WithLogger(GinkgoT()), ) - BeforeEach(func() { - err := CreateLedger(ctx, testServer.GetValue(), operations.V2CreateLedgerRequest{ + BeforeEach(func(specContext SpecContext) { + _, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.CreateLedger(ctx, operations.V2CreateLedgerRequest{ Ledger: "default", }) Expect(err).To(BeNil()) @@ -47,11 +48,10 @@ var _ = Context("Ledger accounts list API tests", func() { var ( timestamp = time.Now().Round(time.Second).UTC() ) - BeforeEach(func() { + BeforeEach(func(specContext SpecContext) { for i := 0; i < int(txCount); i++ { - _, err := CreateTransaction( + _, err := Wait(specContext, DeferClient(testServer)).Ledger.V2.CreateTransaction( ctx, - testServer.GetValue(), operations.V2CreateTransactionRequest{ V2PostTransaction: components.V2PostTransaction{ Metadata: map[string]string{}, @@ -74,10 +74,12 @@ var _ = Context("Ledger accounts list API tests", func() { When("Listing balances using v1 endpoint", func() { var ( rsp *operations.GetBalancesResponse - err error ) - BeforeEach(func() { - rsp, err = Client(testServer.GetValue()).Ledger.V1.GetBalances( + BeforeEach(func(specContext SpecContext) { + testServer, err := testServer.Wait(specContext) + Expect(err).ToNot(HaveOccurred()) + + rsp, err = Client(testServer).Ledger.V1.GetBalances( ctx, operations.GetBalancesRequest{ Ledger: "default", diff --git a/test/stress/stress_test.go b/test/stress/stress_test.go index dfffa363ee..e97023e9c2 100644 --- a/test/stress/stress_test.go +++ b/test/stress/stress_test.go @@ -4,9 +4,10 @@ package test_suite import ( "fmt" - "github.com/formancehq/go-libs/v2/testing/deferred" + . "github.com/formancehq/go-libs/v2/testing/deferred/ginkgo" "github.com/formancehq/go-libs/v2/testing/testservice" "github.com/formancehq/ledger/pkg/features" + . "github.com/formancehq/ledger/pkg/testserver/ginkgo" "math/big" "math/rand" "sync" @@ -30,7 +31,7 @@ var _ = Context("Ledger stress tests", func() { ) testServer := DeferTestServer( - deferred.DeferMap(db, (*pgtesting.Database).ConnectionOptions), + DeferMap(db, (*pgtesting.Database).ConnectionOptions), testservice.WithInstruments( ExperimentalFeaturesInstrumentation(), ), @@ -44,11 +45,11 @@ var _ = Context("Ledger stress tests", func() { ) When(fmt.Sprintf("creating %d ledgers dispatched on %d buckets", countLedgers, countLedgers/10), func() { - BeforeEach(func() { + BeforeEach(func(ctx SpecContext) { for i := range countLedgers { bucketName := fmt.Sprintf("bucket%d", i/countBuckets) ledgerName := fmt.Sprintf("ledger%d", i) - err := CreateLedger(ctx, testServer.GetValue(), operations.V2CreateLedgerRequest{ + _, err := Wait(ctx, DeferClient(testServer)).Ledger.V2.CreateLedger(ctx, operations.V2CreateLedgerRequest{ Ledger: ledgerName, V2CreateLedgerRequest: components.V2CreateLedgerRequest{ Bucket: &bucketName, @@ -71,7 +72,7 @@ var _ = Context("Ledger stress tests", func() { defer GinkgoRecover() ledger := fmt.Sprintf("ledger%d", rand.Intn(countLedgers)) - createdTx, err := CreateTransaction(ctx, testServer.GetValue(), operations.V2CreateTransactionRequest{ + createdTx, err := Wait(ctx, DeferClient(testServer)).Ledger.V2.CreateTransaction(ctx, operations.V2CreateTransactionRequest{ Ledger: ledger, V2PostTransaction: components.V2PostTransaction{ Postings: []components.V2Posting{ @@ -96,7 +97,7 @@ var _ = Context("Ledger stress tests", func() { if createdTransactions[ledger] == nil { createdTransactions[ledger] = []*big.Int{} } - createdTransactions[ledger] = append(createdTransactions[ledger], createdTx.ID) + createdTransactions[ledger] = append(createdTransactions[ledger], createdTx.V2CreateTransactionResponse.Data.ID) mu.Unlock() }) go func() { @@ -107,7 +108,7 @@ var _ = Context("Ledger stress tests", func() { }) When("getting aggregated volumes with no parameters", func() { It("should be zero", func() { - Expect(testServer.GetValue()).To(HaveCoherentState()) + Expect(testServer).To(HaveCoherentState()) }) }) When("trying to revert concurrently all transactions", func() { @@ -129,7 +130,7 @@ var _ = Context("Ledger stress tests", func() { wp.Submit(func() { defer GinkgoRecover() - _, err := RevertTransaction(ctx, testServer.GetValue(), operations.V2RevertTransactionRequest{ + _, err := Wait(ctx, DeferClient(testServer)).Ledger.V2.RevertTransaction(ctx, operations.V2RevertTransactionRequest{ Ledger: ledger, ID: id, Force: pointer.For(true), @@ -149,7 +150,7 @@ var _ = Context("Ledger stress tests", func() { Expect(failures.Load()).To(Equal(int64(duplicates * countTransactions))) }) By("we should still have the aggregated balances to 0", func() { - Expect(testServer.GetValue()).To(HaveCoherentState()) + Expect(testServer).To(HaveCoherentState()) }) }) }) diff --git a/tools/generator/go.mod b/tools/generator/go.mod index 87e0e6b1e4..63cdfb2f56 100644 --- a/tools/generator/go.mod +++ b/tools/generator/go.mod @@ -9,7 +9,7 @@ replace github.com/formancehq/ledger => ../.. replace github.com/formancehq/ledger/pkg/client => ../../pkg/client require ( - github.com/formancehq/go-libs/v2 v2.2.3-0.20250404084034-ca6bcdb75003 + github.com/formancehq/go-libs/v2 v2.2.3-0.20250404150347-dfce43bb3362 github.com/formancehq/ledger v0.0.0-00010101000000-000000000000 github.com/formancehq/ledger/pkg/client v0.0.0-00010101000000-000000000000 github.com/spf13/cobra v1.9.1 diff --git a/tools/generator/go.sum b/tools/generator/go.sum index 729d67c455..101cbfd72e 100644 --- a/tools/generator/go.sum +++ b/tools/generator/go.sum @@ -102,8 +102,8 @@ github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= -github.com/formancehq/go-libs/v2 v2.2.3-0.20250404084034-ca6bcdb75003 h1:GEhD0mORxEGa9in2R/AKRLqubsdXYTjaxnNFEtT10FQ= -github.com/formancehq/go-libs/v2 v2.2.3-0.20250404084034-ca6bcdb75003/go.mod h1:to6sgzwqspeTKlAF0Vdj/13EMHc8oYNc2gJfxf7hrt8= +github.com/formancehq/go-libs/v2 v2.2.3-0.20250404150347-dfce43bb3362 h1:UN4aVIj4qnzAeYEoz6mvWaAPWvx+CO+HXFEWac/8cv4= +github.com/formancehq/go-libs/v2 v2.2.3-0.20250404150347-dfce43bb3362/go.mod h1:to6sgzwqspeTKlAF0Vdj/13EMHc8oYNc2gJfxf7hrt8= github.com/formancehq/numscript v0.0.15 h1:dprjzbPWWPvIYM1o9P4Ppb6LKs4UuZw3AYeHy78b06k= github.com/formancehq/numscript v0.0.15/go.mod h1:P8qnq15PyWUuhskZdsrzTTqVS5CBkhakDKEPAyF4oYQ= github.com/fsnotify/fsnotify v1.8.0 h1:dAwr6QBTBZIkG8roQaJjGof0pp0EeF+tNV7YBP3F/8M= @@ -238,8 +238,6 @@ github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/onsi/ginkgo/v2 v2.22.1 h1:QW7tbJAUDyVDVOM5dFa7qaybo+CRfR7bemlQUN6Z8aM= github.com/onsi/ginkgo/v2 v2.22.1/go.mod h1:S6aTpoRsSq2cZOd+pssHAlKW/Q/jZt6cPrPlnj4a1xM= -github.com/onsi/gomega v1.36.2 h1:koNYke6TVk6ZmnyHrCXba/T/MoLBXFjeC1PtvYgw0A8= -github.com/onsi/gomega v1.36.2/go.mod h1:DdwyADRjrc825LhMEkD76cHR5+pUnjhUN8GlHlRPHzY= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/image-spec v1.1.0 h1:8SG7/vwALn54lVB/0yZ/MMwhFrPYtpEHQb2IpWsCzug= From ca2917e8d215f7cc16f346b9370588120c1eb522 Mon Sep 17 00:00:00 2001 From: Geoffrey Ragot Date: Mon, 7 Apr 2025 12:36:37 +0200 Subject: [PATCH 4/4] chore: upgrade under go-libs v3 --- cmd/buckets_upgrade.go | 10 ++--- cmd/buckets_upgrade_test.go | 8 ++-- cmd/root.go | 8 ++-- cmd/serve.go | 40 +++++++++---------- cmd/worker.go | 10 ++--- deployments/pulumi/go.mod | 2 +- deployments/pulumi/go.sum | 4 +- deployments/pulumi/pkg/config/config.go | 14 +++---- .../pulumi/pkg/monitoring/monitoring.go | 2 +- go.mod | 2 +- go.sum | 4 +- internal/account.go | 4 +- internal/api/bulking/bulker.go | 4 +- internal/api/bulking/bulker_test.go | 8 ++-- internal/api/bulking/elements.go | 16 ++++---- internal/api/bulking/handler_json.go | 6 +-- internal/api/bulking/handler_json_test.go | 4 +- .../api/bulking/handler_stream_json_test.go | 2 +- .../api/bulking/handler_stream_text_test.go | 2 +- .../bulking/mocks_ledger_controller_test.go | 4 +- internal/api/common/errors.go | 8 ++-- internal/api/common/middleware_logid.go | 2 +- internal/api/common/middleware_resolver.go | 4 +- .../api/common/middleware_resolver_test.go | 4 +- .../common/mocks_ledger_controller_test.go | 4 +- .../common/mocks_system_controller_test.go | 2 +- internal/api/module.go | 4 +- internal/api/router.go | 10 ++--- internal/api/v1/controllers_accounts.go | 2 +- .../v1/controllers_accounts_add_metadata.go | 4 +- .../controllers_accounts_add_metadata_test.go | 6 +-- internal/api/v1/controllers_accounts_count.go | 2 +- .../api/v1/controllers_accounts_count_test.go | 8 ++-- .../controllers_accounts_delete_metadata.go | 2 +- ...ntrollers_accounts_delete_metadata_test.go | 6 +-- internal/api/v1/controllers_accounts_list.go | 2 +- .../api/v1/controllers_accounts_list_test.go | 10 ++--- internal/api/v1/controllers_accounts_read.go | 8 ++-- .../api/v1/controllers_accounts_read_test.go | 8 ++-- .../api/v1/controllers_balances_aggregates.go | 4 +- .../controllers_balances_aggregates_test.go | 6 +-- internal/api/v1/controllers_balances_list.go | 4 +- internal/api/v1/controllers_config.go | 6 +-- internal/api/v1/controllers_config_test.go | 6 +-- internal/api/v1/controllers_info.go | 4 +- internal/api/v1/controllers_info_test.go | 8 ++-- internal/api/v1/controllers_logs_list.go | 6 +-- internal/api/v1/controllers_logs_list_test.go | 12 +++--- internal/api/v1/controllers_stats.go | 2 +- internal/api/v1/controllers_stats_test.go | 4 +- internal/api/v1/controllers_transactions.go | 2 +- .../controllers_transactions_add_metadata.go | 4 +- ...trollers_transactions_add_metadata_test.go | 6 +-- .../api/v1/controllers_transactions_count.go | 2 +- .../v1/controllers_transactions_count_test.go | 8 ++-- .../api/v1/controllers_transactions_create.go | 6 +-- .../controllers_transactions_create_test.go | 8 ++-- ...ontrollers_transactions_delete_metadata.go | 2 +- ...llers_transactions_delete_metadata_test.go | 6 +-- .../api/v1/controllers_transactions_list.go | 4 +- .../v1/controllers_transactions_list_test.go | 12 +++--- .../api/v1/controllers_transactions_read.go | 6 +-- .../v1/controllers_transactions_read_test.go | 6 +-- .../api/v1/controllers_transactions_revert.go | 2 +- .../controllers_transactions_revert_test.go | 6 +-- .../api/v1/middleware_auto_create_ledger.go | 4 +- .../api/v1/mocks_ledger_controller_test.go | 4 +- .../api/v1/mocks_system_controller_test.go | 2 +- internal/api/v1/routes.go | 2 +- internal/api/v1/utils.go | 4 +- internal/api/v2/common.go | 10 ++--- .../v2/controllers_accounts_add_metadata.go | 4 +- .../controllers_accounts_add_metadata_test.go | 6 +-- internal/api/v2/controllers_accounts_count.go | 2 +- .../api/v2/controllers_accounts_count_test.go | 8 ++-- .../controllers_accounts_delete_metadata.go | 2 +- ...ntrollers_accounts_delete_metadata_test.go | 6 +-- internal/api/v2/controllers_accounts_list.go | 2 +- .../api/v2/controllers_accounts_list_test.go | 12 +++--- internal/api/v2/controllers_accounts_read.go | 6 +-- .../api/v2/controllers_accounts_read_test.go | 8 ++-- internal/api/v2/controllers_balances.go | 2 +- internal/api/v2/controllers_balances_test.go | 8 ++-- internal/api/v2/controllers_bulk.go | 2 +- internal/api/v2/controllers_bulk_test.go | 12 +++--- internal/api/v2/controllers_ledgers_create.go | 2 +- .../api/v2/controllers_ledgers_create_test.go | 6 +-- .../v2/controllers_ledgers_delete_metadata.go | 2 +- ...ontrollers_ledgers_delete_metadata_test.go | 6 +-- internal/api/v2/controllers_ledgers_info.go | 4 +- .../api/v2/controllers_ledgers_info_test.go | 8 ++-- internal/api/v2/controllers_ledgers_list.go | 4 +- .../api/v2/controllers_ledgers_list_test.go | 8 ++-- internal/api/v2/controllers_ledgers_read.go | 4 +- .../api/v2/controllers_ledgers_read_test.go | 6 +-- .../v2/controllers_ledgers_update_metadata.go | 4 +- ...ontrollers_ledgers_update_metadata_test.go | 6 +-- .../api/v2/controllers_logs_export_test.go | 4 +- internal/api/v2/controllers_logs_import.go | 2 +- .../api/v2/controllers_logs_import_test.go | 4 +- internal/api/v2/controllers_logs_list.go | 4 +- internal/api/v2/controllers_logs_list_test.go | 12 +++--- internal/api/v2/controllers_stats.go | 2 +- internal/api/v2/controllers_stats_test.go | 4 +- .../controllers_transactions_add_metadata.go | 4 +- ...trollers_transactions_add_metadata_test.go | 6 +-- .../api/v2/controllers_transactions_count.go | 2 +- .../v2/controllers_transactions_count_test.go | 8 ++-- .../api/v2/controllers_transactions_create.go | 2 +- .../controllers_transactions_create_test.go | 6 +-- ...ontrollers_transactions_delete_metadata.go | 2 +- ...llers_transactions_delete_metadata_test.go | 6 +-- .../api/v2/controllers_transactions_list.go | 4 +- .../v2/controllers_transactions_list_test.go | 12 +++--- .../api/v2/controllers_transactions_read.go | 6 +-- .../v2/controllers_transactions_read_test.go | 8 ++-- .../api/v2/controllers_transactions_revert.go | 2 +- .../controllers_transactions_revert_test.go | 4 +- internal/api/v2/controllers_volumes.go | 2 +- internal/api/v2/controllers_volumes_test.go | 10 ++--- .../api/v2/mocks_ledger_controller_test.go | 4 +- .../api/v2/mocks_system_controller_test.go | 2 +- internal/api/v2/query.go | 2 +- internal/api/v2/routes.go | 8 ++-- internal/bus/listener.go | 6 +-- internal/bus/listener_test.go | 2 +- internal/bus/message.go | 6 +-- internal/controller/ledger/controller.go | 6 +-- .../controller/ledger/controller_default.go | 14 +++---- .../ledger/controller_default_test.go | 14 +++---- .../ledger/controller_generated_test.go | 4 +- ...ontroller_with_too_many_client_handling.go | 2 +- ...ller_with_too_many_client_handling_test.go | 6 +-- .../ledger/controller_with_traces.go | 4 +- internal/controller/ledger/errors.go | 2 +- internal/controller/ledger/listener.go | 2 +- .../ledger/listener_generated_test.go | 2 +- internal/controller/ledger/log_process.go | 6 +-- .../controller/ledger/log_process_test.go | 6 +-- internal/controller/ledger/mocks_test.go | 2 +- internal/controller/ledger/numscript.go | 2 +- .../controller/ledger/numscript_runtime.go | 4 +- internal/controller/ledger/stats_test.go | 2 +- internal/controller/ledger/store.go | 12 +++--- .../controller/ledger/store_generated_test.go | 6 +-- internal/controller/system/controller.go | 2 +- internal/controller/system/state_tracker.go | 2 +- internal/controller/system/store.go | 4 +- internal/ledger.go | 4 +- internal/log.go | 6 +-- internal/machine/examples/basic.go | 2 +- internal/machine/funding.go | 2 +- internal/machine/vm/machine.go | 2 +- internal/machine/vm/machine_test.go | 2 +- internal/machine/vm/run.go | 4 +- internal/machine/vm/run_test.go | 2 +- internal/machine/vm/store.go | 2 +- internal/moves.go | 6 +-- internal/storage/bucket/bucket.go | 2 +- internal/storage/bucket/default_bucket.go | 2 +- .../storage/bucket/default_bucket_test.go | 6 +-- internal/storage/bucket/main_test.go | 8 ++-- internal/storage/bucket/migrations.go | 4 +- internal/storage/bucket/migrations_test.go | 8 ++-- internal/storage/common/paginator.go | 2 +- internal/storage/common/paginator_column.go | 4 +- internal/storage/common/paginator_offset.go | 2 +- internal/storage/common/resource.go | 13 +++--- .../storage/driver/buckets_generated_test.go | 2 +- internal/storage/driver/driver.go | 8 ++-- internal/storage/driver/driver_test.go | 6 +-- internal/storage/driver/main_test.go | 10 ++--- internal/storage/driver/module.go | 2 +- internal/storage/driver/rollbacks.go | 2 +- .../storage/driver/system_generated_test.go | 4 +- internal/storage/ledger/accounts.go | 6 +-- internal/storage/ledger/accounts_test.go | 10 ++--- internal/storage/ledger/balances.go | 2 +- internal/storage/ledger/balances_test.go | 10 ++--- internal/storage/ledger/logs.go | 4 +- internal/storage/ledger/logs_test.go | 12 +++--- internal/storage/ledger/main_test.go | 12 +++--- internal/storage/ledger/moves.go | 2 +- internal/storage/ledger/moves_test.go | 8 ++-- internal/storage/ledger/store.go | 6 +-- internal/storage/ledger/transactions.go | 12 +++--- internal/storage/ledger/transactions_test.go | 12 +++--- internal/storage/ledger/volumes.go | 4 +- internal/storage/ledger/volumes_test.go | 12 +++--- internal/storage/module.go | 4 +- internal/storage/system/main_test.go | 8 ++-- internal/storage/system/migrations.go | 6 +-- internal/storage/system/migrations_test.go | 10 ++--- internal/storage/system/store.go | 8 ++-- internal/storage/system/store_test.go | 12 +++--- internal/tracing/tracing.go | 4 +- internal/transaction.go | 6 +-- internal/transaction_test.go | 6 +-- internal/worker/async_block.go | 8 ++-- internal/worker/fx.go | 2 +- pkg/features/features.go | 2 +- pkg/generate/generator.go | 4 +- pkg/generate/generator_test.go | 12 +++--- pkg/generate/set.go | 6 +-- pkg/testserver/client.go | 4 +- pkg/testserver/ginkgo/helpers.go | 8 ++-- pkg/testserver/ginkgo/matchers.go | 8 ++-- pkg/testserver/server.go | 6 +-- pkg/testserver/utils.go | 6 +-- pkg/testserver/worker.go | 2 +- test/e2e/api_accounts_list_test.go | 16 ++++---- test/e2e/api_accounts_metadata_test.go | 12 +++--- test/e2e/api_balances_aggregated_test.go | 10 ++--- test/e2e/api_bulk_test.go | 18 ++++----- test/e2e/api_ledgers_create_test.go | 14 +++---- test/e2e/api_ledgers_import_test.go | 12 +++--- test/e2e/api_ledgers_list_test.go | 10 ++--- test/e2e/api_ledgers_metadata_test.go | 8 ++-- test/e2e/api_logs_list_test.go | 10 ++--- test/e2e/api_transactions_create_test.go | 18 ++++----- test/e2e/api_transactions_list_test.go | 20 +++++----- test/e2e/api_transactions_metadata_test.go | 10 ++--- test/e2e/api_transactions_revert_test.go | 16 ++++---- test/e2e/api_volumes_test.go | 10 ++--- test/e2e/app_lifecycle_test.go | 16 ++++---- test/e2e/app_logs_blocks_async_test.go | 10 ++--- test/e2e/app_multiple_instance_test.go | 8 ++-- test/e2e/suite_test.go | 14 +++---- test/e2e/v1_api_balances_test.go | 10 ++--- test/migrations/upgrade_test.go | 8 ++-- test/performance/pkg/env/configure.go | 2 +- test/performance/pkg/env/features.go | 2 +- test/performance/pkg/read/read_test.go | 4 +- test/performance/pkg/write/local_env_test.go | 14 +++---- test/performance/pkg/write/report_test.go | 2 +- test/performance/pkg/write/write_test.go | 6 +-- test/stress/stress_test.go | 10 ++--- test/stress/suite_test.go | 8 ++-- tools/generator/cmd/root.go | 2 +- tools/generator/go.mod | 2 +- tools/generator/go.sum | 4 +- tools/provisioner/go.mod | 4 +- tools/provisioner/go.sum | 8 ++-- tools/provisioner/pkg/reconciler.go | 2 +- tools/provisioner/pkg/store.go | 2 +- 245 files changed, 746 insertions(+), 745 deletions(-) diff --git a/cmd/buckets_upgrade.go b/cmd/buckets_upgrade.go index fc3b6a9baf..05149ddbb1 100644 --- a/cmd/buckets_upgrade.go +++ b/cmd/buckets_upgrade.go @@ -1,11 +1,11 @@ package cmd import ( - "github.com/formancehq/go-libs/v2/bun/bunconnect" - "github.com/formancehq/go-libs/v2/logging" - "github.com/formancehq/go-libs/v2/otlp" - "github.com/formancehq/go-libs/v2/otlp/otlptraces" - "github.com/formancehq/go-libs/v2/service" + "github.com/formancehq/go-libs/v3/bun/bunconnect" + "github.com/formancehq/go-libs/v3/logging" + "github.com/formancehq/go-libs/v3/otlp" + "github.com/formancehq/go-libs/v3/otlp/otlptraces" + "github.com/formancehq/go-libs/v3/service" "github.com/formancehq/ledger/internal/storage" "github.com/formancehq/ledger/internal/storage/driver" "github.com/spf13/cobra" diff --git a/cmd/buckets_upgrade_test.go b/cmd/buckets_upgrade_test.go index ab990c54ce..46ea29bfea 100644 --- a/cmd/buckets_upgrade_test.go +++ b/cmd/buckets_upgrade_test.go @@ -6,10 +6,10 @@ import ( "io" "testing" - "github.com/formancehq/go-libs/v2/bun/bunconnect" - "github.com/formancehq/go-libs/v2/logging" - "github.com/formancehq/go-libs/v2/testing/docker" - "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" + "github.com/formancehq/go-libs/v3/bun/bunconnect" + "github.com/formancehq/go-libs/v3/logging" + "github.com/formancehq/go-libs/v3/testing/docker" + "github.com/formancehq/go-libs/v3/testing/platform/pgtesting" "github.com/stretchr/testify/require" ) diff --git a/cmd/root.go b/cmd/root.go index 26fac24fb1..2a7a406b9e 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -1,10 +1,10 @@ package cmd import ( - "github.com/formancehq/go-libs/v2/bun/bunmigrate" - "github.com/formancehq/go-libs/v2/otlp" - "github.com/formancehq/go-libs/v2/otlp/otlptraces" - "github.com/formancehq/go-libs/v2/service" + "github.com/formancehq/go-libs/v3/bun/bunmigrate" + "github.com/formancehq/go-libs/v3/otlp" + "github.com/formancehq/go-libs/v3/otlp/otlptraces" + "github.com/formancehq/go-libs/v3/service" "github.com/formancehq/ledger/internal/storage/driver" "github.com/spf13/cobra" "github.com/uptrace/bun" diff --git a/cmd/serve.go b/cmd/serve.go index 7aa7e92cc7..3009af8597 100644 --- a/cmd/serve.go +++ b/cmd/serve.go @@ -2,7 +2,7 @@ package cmd import ( "fmt" - "github.com/formancehq/go-libs/v2/logging" + "github.com/formancehq/go-libs/v3/logging" "github.com/formancehq/ledger/internal/api/common" systemstore "github.com/formancehq/ledger/internal/storage/system" "github.com/formancehq/ledger/internal/worker" @@ -10,29 +10,29 @@ import ( "net/http/pprof" "time" - apilib "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/health" - "github.com/formancehq/go-libs/v2/httpserver" - "github.com/formancehq/go-libs/v2/otlp" + apilib "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/health" + "github.com/formancehq/go-libs/v3/httpserver" + "github.com/formancehq/go-libs/v3/otlp" "github.com/go-chi/chi/v5" "go.opentelemetry.io/otel/sdk/metric" "github.com/formancehq/ledger/internal/bus" - "github.com/formancehq/go-libs/v2/auth" - "github.com/formancehq/go-libs/v2/aws/iam" - "github.com/formancehq/go-libs/v2/bun/bunconnect" - "github.com/formancehq/go-libs/v2/otlp/otlpmetrics" - "github.com/formancehq/go-libs/v2/otlp/otlptraces" - "github.com/formancehq/go-libs/v2/publish" + "github.com/formancehq/go-libs/v3/auth" + "github.com/formancehq/go-libs/v3/aws/iam" + "github.com/formancehq/go-libs/v3/bun/bunconnect" + "github.com/formancehq/go-libs/v3/otlp/otlpmetrics" + "github.com/formancehq/go-libs/v3/otlp/otlptraces" + "github.com/formancehq/go-libs/v3/publish" "github.com/formancehq/ledger/internal/api" ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" systemcontroller "github.com/formancehq/ledger/internal/controller/system" "github.com/formancehq/ledger/internal/storage" - "github.com/formancehq/go-libs/v2/ballast" - "github.com/formancehq/go-libs/v2/service" + "github.com/formancehq/go-libs/v3/ballast" + "github.com/formancehq/go-libs/v3/service" "github.com/spf13/cobra" "go.uber.org/fx" ) @@ -125,15 +125,15 @@ func NewServeCommand() *cobra.Command { }), fx.Decorate(func( params struct { - fx.In + fx.In - Handler chi.Router - HealthController *health.HealthController - Logger logging.Logger + Handler chi.Router + HealthController *health.HealthController + Logger logging.Logger - MeterProvider *metric.MeterProvider `optional:"true"` - Exporter *otlpmetrics.InMemoryExporter `optional:"true"` - }, + MeterProvider *metric.MeterProvider `optional:"true"` + Exporter *otlpmetrics.InMemoryExporter `optional:"true"` + }, ) chi.Router { return assembleFinalRouter( service.IsDebug(cmd), diff --git a/cmd/worker.go b/cmd/worker.go index aca72e70d7..cb709f36b9 100644 --- a/cmd/worker.go +++ b/cmd/worker.go @@ -2,11 +2,11 @@ package cmd import ( "fmt" - "github.com/formancehq/go-libs/v2/bun/bunconnect" - "github.com/formancehq/go-libs/v2/otlp" - "github.com/formancehq/go-libs/v2/otlp/otlpmetrics" - "github.com/formancehq/go-libs/v2/otlp/otlptraces" - "github.com/formancehq/go-libs/v2/service" + "github.com/formancehq/go-libs/v3/bun/bunconnect" + "github.com/formancehq/go-libs/v3/otlp" + "github.com/formancehq/go-libs/v3/otlp/otlpmetrics" + "github.com/formancehq/go-libs/v3/otlp/otlptraces" + "github.com/formancehq/go-libs/v3/service" "github.com/formancehq/ledger/internal/storage" "github.com/formancehq/ledger/internal/worker" "github.com/spf13/cobra" diff --git a/deployments/pulumi/go.mod b/deployments/pulumi/go.mod index 18d1f6f3ba..da781f259a 100644 --- a/deployments/pulumi/go.mod +++ b/deployments/pulumi/go.mod @@ -5,7 +5,7 @@ go 1.23.1 toolchain go1.23.3 require ( - github.com/formancehq/go-libs/v2 v2.2.2 + github.com/formancehq/go-libs/v3 v3.0.0-20250407102820-68fa020e67bb github.com/google/uuid v1.6.0 github.com/invopop/jsonschema v0.13.0 github.com/kos-v/dsnparser v1.1.0 diff --git a/deployments/pulumi/go.sum b/deployments/pulumi/go.sum index 0400411827..c067398b83 100644 --- a/deployments/pulumi/go.sum +++ b/deployments/pulumi/go.sum @@ -146,8 +146,8 @@ github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= -github.com/formancehq/go-libs/v2 v2.2.2 h1:COVo8+wIybiiocw4NWl3W0dovQgkO/b/P1jTk1ItKGw= -github.com/formancehq/go-libs/v2 v2.2.2/go.mod h1:vIUz00DsuhjrRV7mimv3V/VXhYDRQXAEh2KWW16CAtM= +github.com/formancehq/go-libs/v3 v3.0.0-20250407102820-68fa020e67bb h1:bX/OQdZJryJlOzc1Ao8mMKg1kV9qSmmJ1aHxv5N71HE= +github.com/formancehq/go-libs/v3 v3.0.0-20250407102820-68fa020e67bb/go.mod h1:mRr5/y0I64iJ4I+BXNkUy49izwrh3SA5L+MTWD1d/7Q= github.com/gliderlabs/ssh v0.3.8 h1:a4YXD1V7xMF9g5nTkdfnja3Sxy1PVDCj1Zg4Wb8vY6c= github.com/gliderlabs/ssh v0.3.8/go.mod h1:xYoytBv1sV0aL3CavoDuJIQNURXkkfPA/wxQ1pL1fAU= github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI= diff --git a/deployments/pulumi/pkg/config/config.go b/deployments/pulumi/pkg/config/config.go index 71f3c5fdfc..b8f7e22a63 100644 --- a/deployments/pulumi/pkg/config/config.go +++ b/deployments/pulumi/pkg/config/config.go @@ -3,7 +3,7 @@ package config import ( "errors" "fmt" - . "github.com/formancehq/go-libs/v2/collectionutils" + . "github.com/formancehq/go-libs/v3/collectionutils" pulumi_ledger "github.com/formancehq/ledger/deployments/pulumi/pkg" "github.com/formancehq/ledger/deployments/pulumi/pkg/api" "github.com/formancehq/ledger/deployments/pulumi/pkg/common" @@ -70,7 +70,7 @@ func (a *RDSPostMigrateSnapshot) toInput() *storage.RDSPostMigrateSnapshotArgs { } return &storage.RDSPostMigrateSnapshotArgs{ SnapshotIdentifier: pulumi.String(a.SnapshotIdentifier), - RetainsOnDelete: a.RetainsOnDelete, + RetainsOnDelete: a.RetainsOnDelete, } } @@ -140,7 +140,7 @@ func (a RDSClusterCreate) toInput() *storage.RDSClusterCreateArgs { InstanceClass: pulumix.Val(rds.InstanceType(a.InstanceClass)), Engine: pulumi.String(a.Engine), EngineVersion: pulumi.String(a.EngineVersion), - RetainsOnDelete: a.RetainsOnDelete, + RetainsOnDelete: a.RetainsOnDelete, } } @@ -247,7 +247,7 @@ func (s Storage) toInput() storage.Args { RDS: s.RDS.toInput(), ConnectivityDatabaseArgs: s.Connectivity.toInput(), DisableUpgrade: pulumix.Val(s.DisableUpgrade), - Service: s.Service.toInput(), + Service: s.Service.toInput(), } } @@ -540,7 +540,7 @@ func (g GeneratorLedgerConfiguration) toInput() generator.LedgerConfiguration { ScriptFromFile: pulumix.Val(g.ScriptFromFile), VUs: pulumix.Val(g.VUs), HTTPClientTimeout: pulumix.Val(g.HTTPClientTimeout), - SkipAwait: pulumix.Val(g.SkipAwait), + SkipAwait: pulumix.Val(g.SkipAwait), } } @@ -558,8 +558,8 @@ func (g *Generator) toInput() *generator.Args { } return &generator.Args{ - GeneratorVersion: pulumix.Val(g.GeneratorVersion), - Ledgers: ConvertMap(g.Ledgers, GeneratorLedgerConfiguration.toInput), + GeneratorVersion: pulumix.Val(g.GeneratorVersion), + Ledgers: ConvertMap(g.Ledgers, GeneratorLedgerConfiguration.toInput), } } diff --git a/deployments/pulumi/pkg/monitoring/monitoring.go b/deployments/pulumi/pkg/monitoring/monitoring.go index 1c56b9d29e..eae9fa3984 100644 --- a/deployments/pulumi/pkg/monitoring/monitoring.go +++ b/deployments/pulumi/pkg/monitoring/monitoring.go @@ -1,7 +1,7 @@ package monitoring import ( - "github.com/formancehq/go-libs/v2/collectionutils" + "github.com/formancehq/go-libs/v3/collectionutils" "github.com/formancehq/ledger/deployments/pulumi/pkg/utils" corev1 "github.com/pulumi/pulumi-kubernetes/sdk/v4/go/kubernetes/core/v1" "github.com/pulumi/pulumi/sdk/v3/go/pulumi" diff --git a/go.mod b/go.mod index c93a4e688e..b2eda51113 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,6 @@ require ( github.com/antlr/antlr4/runtime/Go/antlr v1.4.10 github.com/bluele/gcache v0.0.2 github.com/dop251/goja v0.0.0-20241009100908-5f46f2705ca3 - github.com/formancehq/go-libs/v2 v2.2.3-0.20250404150347-dfce43bb3362 github.com/formancehq/ledger/pkg/client v0.0.0-00010101000000-000000000000 github.com/go-chi/chi/v5 v5.2.1 github.com/go-chi/cors v1.2.1 @@ -51,6 +50,7 @@ require ( ) require ( + github.com/formancehq/go-libs/v3 v3.0.0-20250408113106-7b3525e0b25b github.com/robfig/cron/v3 v3.0.1 github.com/spf13/viper v1.20.1 gopkg.in/yaml.v3 v3.0.1 diff --git a/go.sum b/go.sum index b8c9d9c468..7524e1588e 100644 --- a/go.sum +++ b/go.sum @@ -104,8 +104,8 @@ github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= -github.com/formancehq/go-libs/v2 v2.2.3-0.20250404150347-dfce43bb3362 h1:UN4aVIj4qnzAeYEoz6mvWaAPWvx+CO+HXFEWac/8cv4= -github.com/formancehq/go-libs/v2 v2.2.3-0.20250404150347-dfce43bb3362/go.mod h1:to6sgzwqspeTKlAF0Vdj/13EMHc8oYNc2gJfxf7hrt8= +github.com/formancehq/go-libs/v3 v3.0.0-20250408113106-7b3525e0b25b h1:EvnYMGyZo+fq9fsrraedKBlVTbeE2mqpJ/edj8FRTtU= +github.com/formancehq/go-libs/v3 v3.0.0-20250408113106-7b3525e0b25b/go.mod h1:mRr5/y0I64iJ4I+BXNkUy49izwrh3SA5L+MTWD1d/7Q= github.com/formancehq/numscript v0.0.15 h1:dprjzbPWWPvIYM1o9P4Ppb6LKs4UuZw3AYeHy78b06k= github.com/formancehq/numscript v0.0.15/go.mod h1:P8qnq15PyWUuhskZdsrzTTqVS5CBkhakDKEPAyF4oYQ= github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= diff --git a/internal/account.go b/internal/account.go index add2235203..d46ccb751c 100644 --- a/internal/account.go +++ b/internal/account.go @@ -1,8 +1,8 @@ package ledger import ( - "github.com/formancehq/go-libs/v2/metadata" - "github.com/formancehq/go-libs/v2/time" + "github.com/formancehq/go-libs/v3/metadata" + "github.com/formancehq/go-libs/v3/time" "github.com/uptrace/bun" "math/big" ) diff --git a/internal/api/bulking/bulker.go b/internal/api/bulking/bulker.go index 4576a1f3d4..0fbd40780a 100644 --- a/internal/api/bulking/bulker.go +++ b/internal/api/bulking/bulker.go @@ -6,8 +6,8 @@ import ( "errors" "fmt" "github.com/alitto/pond" - "github.com/formancehq/go-libs/v2/logging" - "github.com/formancehq/go-libs/v2/otlp" + "github.com/formancehq/go-libs/v3/logging" + "github.com/formancehq/go-libs/v3/otlp" ledger "github.com/formancehq/ledger/internal" ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" "go.opentelemetry.io/otel/attribute" diff --git a/internal/api/bulking/bulker_test.go b/internal/api/bulking/bulker_test.go index 42f463a17b..c6dce3bd6e 100644 --- a/internal/api/bulking/bulker_test.go +++ b/internal/api/bulking/bulker_test.go @@ -2,18 +2,18 @@ package bulking import ( "encoding/json" - "github.com/formancehq/go-libs/v2/logging" - "github.com/formancehq/go-libs/v2/pointer" + "github.com/formancehq/go-libs/v3/logging" + "github.com/formancehq/go-libs/v3/pointer" "github.com/uptrace/bun" "math/big" "testing" ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" - "github.com/formancehq/go-libs/v2/time" + "github.com/formancehq/go-libs/v3/time" "errors" - "github.com/formancehq/go-libs/v2/metadata" + "github.com/formancehq/go-libs/v3/metadata" ledger "github.com/formancehq/ledger/internal" "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" diff --git a/internal/api/bulking/elements.go b/internal/api/bulking/elements.go index 84cbed0603..88d6fdc2c2 100644 --- a/internal/api/bulking/elements.go +++ b/internal/api/bulking/elements.go @@ -3,8 +3,8 @@ package bulking import ( "encoding/json" "fmt" - "github.com/formancehq/go-libs/v2/metadata" - "github.com/formancehq/go-libs/v2/time" + "github.com/formancehq/go-libs/v3/metadata" + "github.com/formancehq/go-libs/v3/time" ledger "github.com/formancehq/ledger/internal" ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" "reflect" @@ -94,11 +94,11 @@ type DeleteMetadataRequest struct { } type TransactionRequest struct { - Postings ledger.Postings `json:"postings"` - Script ledgercontroller.ScriptV1 `json:"script"` - Timestamp time.Time `json:"timestamp"` - Reference string `json:"reference"` - Metadata metadata.Metadata `json:"metadata" swaggertype:"object"` + Postings ledger.Postings `json:"postings"` + Script ledgercontroller.ScriptV1 `json:"script"` + Timestamp time.Time `json:"timestamp"` + Reference string `json:"reference"` + Metadata metadata.Metadata `json:"metadata" swaggertype:"object"` AccountMetadata map[string]metadata.Metadata `json:"accountMetadata"` } @@ -131,4 +131,4 @@ func (req TransactionRequest) ToCore(allowUnboundedOverdrafts bool) (*ledgercont RunScript: runScript, AccountMetadata: req.AccountMetadata, }, nil -} \ No newline at end of file +} diff --git a/internal/api/bulking/handler_json.go b/internal/api/bulking/handler_json.go index 6cfd96f2a7..b7c5b47e42 100644 --- a/internal/api/bulking/handler_json.go +++ b/internal/api/bulking/handler_json.go @@ -4,9 +4,9 @@ import ( "encoding/json" "errors" "fmt" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/collectionutils" - "github.com/formancehq/go-libs/v2/pointer" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/collectionutils" + "github.com/formancehq/go-libs/v3/pointer" "github.com/formancehq/ledger/internal/api/common" ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" "net/http" diff --git a/internal/api/bulking/handler_json_test.go b/internal/api/bulking/handler_json_test.go index fdce30a69f..ffe7fed196 100644 --- a/internal/api/bulking/handler_json_test.go +++ b/internal/api/bulking/handler_json_test.go @@ -3,8 +3,8 @@ package bulking import ( "bytes" "encoding/json" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/time" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/time" ledger "github.com/formancehq/ledger/internal" ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" "github.com/stretchr/testify/require" diff --git a/internal/api/bulking/handler_stream_json_test.go b/internal/api/bulking/handler_stream_json_test.go index 0c7856c32a..cb68fd6bea 100644 --- a/internal/api/bulking/handler_stream_json_test.go +++ b/internal/api/bulking/handler_stream_json_test.go @@ -1,7 +1,7 @@ package bulking import ( - "github.com/formancehq/go-libs/v2/api" + "github.com/formancehq/go-libs/v3/api" ledger "github.com/formancehq/ledger/internal" "github.com/stretchr/testify/require" "io" diff --git a/internal/api/bulking/handler_stream_text_test.go b/internal/api/bulking/handler_stream_text_test.go index f5e79b87f7..20b44b1556 100644 --- a/internal/api/bulking/handler_stream_text_test.go +++ b/internal/api/bulking/handler_stream_text_test.go @@ -1,7 +1,7 @@ package bulking import ( - "github.com/formancehq/go-libs/v2/api" + "github.com/formancehq/go-libs/v3/api" ledger "github.com/formancehq/ledger/internal" "github.com/stretchr/testify/require" "io" diff --git a/internal/api/bulking/mocks_ledger_controller_test.go b/internal/api/bulking/mocks_ledger_controller_test.go index 2172801a2b..fd58b0bc81 100644 --- a/internal/api/bulking/mocks_ledger_controller_test.go +++ b/internal/api/bulking/mocks_ledger_controller_test.go @@ -12,8 +12,8 @@ import ( sql "database/sql" reflect "reflect" - bunpaginate "github.com/formancehq/go-libs/v2/bun/bunpaginate" - migrations "github.com/formancehq/go-libs/v2/migrations" + bunpaginate "github.com/formancehq/go-libs/v3/bun/bunpaginate" + migrations "github.com/formancehq/go-libs/v3/migrations" ledger "github.com/formancehq/ledger/internal" ledger0 "github.com/formancehq/ledger/internal/controller/ledger" common "github.com/formancehq/ledger/internal/storage/common" diff --git a/internal/api/common/errors.go b/internal/api/common/errors.go index c0830a9a4f..d9738fa432 100644 --- a/internal/api/common/errors.go +++ b/internal/api/common/errors.go @@ -2,10 +2,10 @@ package common import ( "errors" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/logging" - "github.com/formancehq/go-libs/v2/otlp" - "github.com/formancehq/go-libs/v2/platform/postgres" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/logging" + "github.com/formancehq/go-libs/v3/otlp" + "github.com/formancehq/go-libs/v3/platform/postgres" "net/http" ) diff --git a/internal/api/common/middleware_logid.go b/internal/api/common/middleware_logid.go index 812cde51cf..c8ece37a9a 100644 --- a/internal/api/common/middleware_logid.go +++ b/internal/api/common/middleware_logid.go @@ -8,7 +8,7 @@ import ( "go.opentelemetry.io/otel/trace" - "github.com/formancehq/go-libs/v2/logging" + "github.com/formancehq/go-libs/v3/logging" ) var ( diff --git a/internal/api/common/middleware_resolver.go b/internal/api/common/middleware_resolver.go index f026a8b911..abd22f04a0 100644 --- a/internal/api/common/middleware_resolver.go +++ b/internal/api/common/middleware_resolver.go @@ -5,8 +5,8 @@ import ( "net/http" "strings" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/platform/postgres" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/platform/postgres" "github.com/formancehq/ledger/internal/controller/system" "errors" diff --git a/internal/api/common/middleware_resolver_test.go b/internal/api/common/middleware_resolver_test.go index 42f3bb4374..4d95ebdc53 100644 --- a/internal/api/common/middleware_resolver_test.go +++ b/internal/api/common/middleware_resolver_test.go @@ -8,8 +8,8 @@ import ( "testing" "errors" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/logging" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/logging" ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" diff --git a/internal/api/common/mocks_ledger_controller_test.go b/internal/api/common/mocks_ledger_controller_test.go index d421014c0f..5feb201c42 100644 --- a/internal/api/common/mocks_ledger_controller_test.go +++ b/internal/api/common/mocks_ledger_controller_test.go @@ -12,8 +12,8 @@ import ( sql "database/sql" reflect "reflect" - bunpaginate "github.com/formancehq/go-libs/v2/bun/bunpaginate" - migrations "github.com/formancehq/go-libs/v2/migrations" + bunpaginate "github.com/formancehq/go-libs/v3/bun/bunpaginate" + migrations "github.com/formancehq/go-libs/v3/migrations" ledger "github.com/formancehq/ledger/internal" ledger0 "github.com/formancehq/ledger/internal/controller/ledger" common "github.com/formancehq/ledger/internal/storage/common" diff --git a/internal/api/common/mocks_system_controller_test.go b/internal/api/common/mocks_system_controller_test.go index 326c97f99c..e8ded33b63 100644 --- a/internal/api/common/mocks_system_controller_test.go +++ b/internal/api/common/mocks_system_controller_test.go @@ -11,7 +11,7 @@ import ( context "context" reflect "reflect" - bunpaginate "github.com/formancehq/go-libs/v2/bun/bunpaginate" + bunpaginate "github.com/formancehq/go-libs/v3/bun/bunpaginate" ledger "github.com/formancehq/ledger/internal" ledger0 "github.com/formancehq/ledger/internal/controller/ledger" common "github.com/formancehq/ledger/internal/storage/common" diff --git a/internal/api/module.go b/internal/api/module.go index aafd5de76c..739e4416bd 100644 --- a/internal/api/module.go +++ b/internal/api/module.go @@ -2,8 +2,8 @@ package api import ( _ "embed" - "github.com/formancehq/go-libs/v2/auth" - "github.com/formancehq/go-libs/v2/health" + "github.com/formancehq/go-libs/v3/auth" + "github.com/formancehq/go-libs/v3/health" "github.com/formancehq/ledger/internal/api/bulking" "github.com/formancehq/ledger/internal/api/common" "github.com/formancehq/ledger/internal/controller/system" diff --git a/internal/api/router.go b/internal/api/router.go index e89fc10e6b..28845acb2a 100644 --- a/internal/api/router.go +++ b/internal/api/router.go @@ -2,10 +2,10 @@ package api import ( "fmt" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/bun/bunpaginate" - "github.com/formancehq/go-libs/v2/otlp" - "github.com/formancehq/go-libs/v2/service" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/bun/bunpaginate" + "github.com/formancehq/go-libs/v3/otlp" + "github.com/formancehq/go-libs/v3/service" "github.com/formancehq/ledger/internal/api/bulking" "github.com/formancehq/ledger/internal/controller/system" "go.opentelemetry.io/otel/trace" @@ -15,7 +15,7 @@ import ( "github.com/go-chi/chi/v5/middleware" "github.com/go-chi/cors" - "github.com/formancehq/go-libs/v2/auth" + "github.com/formancehq/go-libs/v3/auth" "github.com/formancehq/ledger/internal/api/common" v1 "github.com/formancehq/ledger/internal/api/v1" v2 "github.com/formancehq/ledger/internal/api/v2" diff --git a/internal/api/v1/controllers_accounts.go b/internal/api/v1/controllers_accounts.go index 8d4e179351..be61cede9b 100644 --- a/internal/api/v1/controllers_accounts.go +++ b/internal/api/v1/controllers_accounts.go @@ -9,7 +9,7 @@ import ( "errors" - "github.com/formancehq/go-libs/v2/query" + "github.com/formancehq/go-libs/v3/query" ledger "github.com/formancehq/ledger/internal" ) diff --git a/internal/api/v1/controllers_accounts_add_metadata.go b/internal/api/v1/controllers_accounts_add_metadata.go index 9e4aeb439f..6e78af89db 100644 --- a/internal/api/v1/controllers_accounts_add_metadata.go +++ b/internal/api/v1/controllers_accounts_add_metadata.go @@ -8,8 +8,8 @@ import ( "net/url" "errors" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/metadata" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/metadata" "github.com/formancehq/ledger/internal/api/common" "github.com/go-chi/chi/v5" ) diff --git a/internal/api/v1/controllers_accounts_add_metadata_test.go b/internal/api/v1/controllers_accounts_add_metadata_test.go index 974b1c6afe..bf9a07c89b 100644 --- a/internal/api/v1/controllers_accounts_add_metadata_test.go +++ b/internal/api/v1/controllers_accounts_add_metadata_test.go @@ -11,9 +11,9 @@ import ( ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/auth" - "github.com/formancehq/go-libs/v2/metadata" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/auth" + "github.com/formancehq/go-libs/v3/metadata" "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" ) diff --git a/internal/api/v1/controllers_accounts_count.go b/internal/api/v1/controllers_accounts_count.go index 09384e8836..e87daa15e4 100644 --- a/internal/api/v1/controllers_accounts_count.go +++ b/internal/api/v1/controllers_accounts_count.go @@ -6,7 +6,7 @@ import ( "net/http" "errors" - "github.com/formancehq/go-libs/v2/api" + "github.com/formancehq/go-libs/v3/api" "github.com/formancehq/ledger/internal/api/common" ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" ) diff --git a/internal/api/v1/controllers_accounts_count_test.go b/internal/api/v1/controllers_accounts_count_test.go index 5fff799d87..8e8299d6e0 100644 --- a/internal/api/v1/controllers_accounts_count_test.go +++ b/internal/api/v1/controllers_accounts_count_test.go @@ -10,10 +10,10 @@ import ( "testing" "errors" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/auth" - "github.com/formancehq/go-libs/v2/query" - "github.com/formancehq/go-libs/v2/time" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/auth" + "github.com/formancehq/go-libs/v3/query" + "github.com/formancehq/go-libs/v3/time" ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" diff --git a/internal/api/v1/controllers_accounts_delete_metadata.go b/internal/api/v1/controllers_accounts_delete_metadata.go index 06c6ab88b3..160a6742d6 100644 --- a/internal/api/v1/controllers_accounts_delete_metadata.go +++ b/internal/api/v1/controllers_accounts_delete_metadata.go @@ -5,7 +5,7 @@ import ( "net/http" "net/url" - "github.com/formancehq/go-libs/v2/api" + "github.com/formancehq/go-libs/v3/api" "github.com/formancehq/ledger/internal/api/common" "github.com/go-chi/chi/v5" ) diff --git a/internal/api/v1/controllers_accounts_delete_metadata_test.go b/internal/api/v1/controllers_accounts_delete_metadata_test.go index 808292dce5..80cf796cec 100644 --- a/internal/api/v1/controllers_accounts_delete_metadata_test.go +++ b/internal/api/v1/controllers_accounts_delete_metadata_test.go @@ -11,9 +11,9 @@ import ( "testing" "errors" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/auth" - "github.com/formancehq/go-libs/v2/logging" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/auth" + "github.com/formancehq/go-libs/v3/logging" ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" diff --git a/internal/api/v1/controllers_accounts_list.go b/internal/api/v1/controllers_accounts_list.go index 6b358547f9..4d70eb1cdd 100644 --- a/internal/api/v1/controllers_accounts_list.go +++ b/internal/api/v1/controllers_accounts_list.go @@ -4,7 +4,7 @@ import ( "net/http" "errors" - "github.com/formancehq/go-libs/v2/api" + "github.com/formancehq/go-libs/v3/api" "github.com/formancehq/ledger/internal/api/common" ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" ) diff --git a/internal/api/v1/controllers_accounts_list_test.go b/internal/api/v1/controllers_accounts_list_test.go index 7a575702a0..c60242d11c 100644 --- a/internal/api/v1/controllers_accounts_list_test.go +++ b/internal/api/v1/controllers_accounts_list_test.go @@ -9,11 +9,11 @@ import ( "os" "testing" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/auth" - "github.com/formancehq/go-libs/v2/bun/bunpaginate" - "github.com/formancehq/go-libs/v2/metadata" - "github.com/formancehq/go-libs/v2/query" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/auth" + "github.com/formancehq/go-libs/v3/bun/bunpaginate" + "github.com/formancehq/go-libs/v3/metadata" + "github.com/formancehq/go-libs/v3/query" ledger "github.com/formancehq/ledger/internal" ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" "github.com/stretchr/testify/require" diff --git a/internal/api/v1/controllers_accounts_read.go b/internal/api/v1/controllers_accounts_read.go index 774c2c631d..ff6ee28a08 100644 --- a/internal/api/v1/controllers_accounts_read.go +++ b/internal/api/v1/controllers_accounts_read.go @@ -1,14 +1,14 @@ package v1 import ( - "github.com/formancehq/go-libs/v2/query" + "github.com/formancehq/go-libs/v3/query" storagecommon "github.com/formancehq/ledger/internal/storage/common" "net/http" "net/url" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/metadata" - "github.com/formancehq/go-libs/v2/platform/postgres" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/metadata" + "github.com/formancehq/go-libs/v3/platform/postgres" ledger "github.com/formancehq/ledger/internal" "github.com/formancehq/ledger/internal/api/common" "github.com/go-chi/chi/v5" diff --git a/internal/api/v1/controllers_accounts_read_test.go b/internal/api/v1/controllers_accounts_read_test.go index 311f31483d..fa59b3953b 100644 --- a/internal/api/v1/controllers_accounts_read_test.go +++ b/internal/api/v1/controllers_accounts_read_test.go @@ -2,7 +2,7 @@ package v1 import ( "bytes" - "github.com/formancehq/go-libs/v2/query" + "github.com/formancehq/go-libs/v3/query" "github.com/formancehq/ledger/internal/api/common" storagecommon "github.com/formancehq/ledger/internal/storage/common" "net/http" @@ -11,9 +11,9 @@ import ( "os" "testing" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/auth" - "github.com/formancehq/go-libs/v2/platform/postgres" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/auth" + "github.com/formancehq/go-libs/v3/platform/postgres" ledger "github.com/formancehq/ledger/internal" "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" diff --git a/internal/api/v1/controllers_balances_aggregates.go b/internal/api/v1/controllers_balances_aggregates.go index 135a5791ab..f60e4b3630 100644 --- a/internal/api/v1/controllers_balances_aggregates.go +++ b/internal/api/v1/controllers_balances_aggregates.go @@ -3,8 +3,8 @@ package v1 import ( "net/http" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/query" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/query" "github.com/formancehq/ledger/internal/api/common" ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" ) diff --git a/internal/api/v1/controllers_balances_aggregates_test.go b/internal/api/v1/controllers_balances_aggregates_test.go index 6ef68be485..f954f12ecb 100644 --- a/internal/api/v1/controllers_balances_aggregates_test.go +++ b/internal/api/v1/controllers_balances_aggregates_test.go @@ -11,9 +11,9 @@ import ( ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/auth" - "github.com/formancehq/go-libs/v2/query" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/auth" + "github.com/formancehq/go-libs/v3/query" ledger "github.com/formancehq/ledger/internal" "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" diff --git a/internal/api/v1/controllers_balances_list.go b/internal/api/v1/controllers_balances_list.go index 397e1bb931..491d9a5870 100644 --- a/internal/api/v1/controllers_balances_list.go +++ b/internal/api/v1/controllers_balances_list.go @@ -4,8 +4,8 @@ import ( "math/big" "net/http" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/bun/bunpaginate" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/bun/bunpaginate" "github.com/formancehq/ledger/internal/api/common" ) diff --git a/internal/api/v1/controllers_config.go b/internal/api/v1/controllers_config.go index 6c29731599..89cf49c42d 100644 --- a/internal/api/v1/controllers_config.go +++ b/internal/api/v1/controllers_config.go @@ -10,12 +10,12 @@ import ( ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" "github.com/formancehq/ledger/internal/controller/system" - "github.com/formancehq/go-libs/v2/bun/bunpaginate" + "github.com/formancehq/go-libs/v3/bun/bunpaginate" ledger "github.com/formancehq/ledger/internal" - "github.com/formancehq/go-libs/v2/collectionutils" + "github.com/formancehq/go-libs/v3/collectionutils" - "github.com/formancehq/go-libs/v2/api" + "github.com/formancehq/go-libs/v3/api" ) type ConfigInfo struct { diff --git a/internal/api/v1/controllers_config_test.go b/internal/api/v1/controllers_config_test.go index 3d162123cb..fe8e2bc063 100644 --- a/internal/api/v1/controllers_config_test.go +++ b/internal/api/v1/controllers_config_test.go @@ -8,10 +8,10 @@ import ( ledger "github.com/formancehq/ledger/internal" - "github.com/formancehq/go-libs/v2/bun/bunpaginate" + "github.com/formancehq/go-libs/v3/bun/bunpaginate" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/auth" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/auth" "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" diff --git a/internal/api/v1/controllers_info.go b/internal/api/v1/controllers_info.go index 5fe9f4245e..9eb54d3387 100644 --- a/internal/api/v1/controllers_info.go +++ b/internal/api/v1/controllers_info.go @@ -5,8 +5,8 @@ import ( "github.com/go-chi/chi/v5" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/migrations" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/migrations" "github.com/formancehq/ledger/internal/api/common" ) diff --git a/internal/api/v1/controllers_info_test.go b/internal/api/v1/controllers_info_test.go index 95b618a43e..5512bba9e8 100644 --- a/internal/api/v1/controllers_info_test.go +++ b/internal/api/v1/controllers_info_test.go @@ -6,11 +6,11 @@ import ( "os" "testing" - "github.com/formancehq/go-libs/v2/time" + "github.com/formancehq/go-libs/v3/time" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/auth" - "github.com/formancehq/go-libs/v2/migrations" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/auth" + "github.com/formancehq/go-libs/v3/migrations" "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" ) diff --git a/internal/api/v1/controllers_logs_list.go b/internal/api/v1/controllers_logs_list.go index ca4d41ae57..f4085ec7d2 100644 --- a/internal/api/v1/controllers_logs_list.go +++ b/internal/api/v1/controllers_logs_list.go @@ -3,9 +3,9 @@ package v1 import ( "net/http" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/bun/bunpaginate" - "github.com/formancehq/go-libs/v2/query" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/bun/bunpaginate" + "github.com/formancehq/go-libs/v3/query" "github.com/formancehq/ledger/internal/api/common" ) diff --git a/internal/api/v1/controllers_logs_list_test.go b/internal/api/v1/controllers_logs_list_test.go index cdd3f82077..ee2b737f7c 100644 --- a/internal/api/v1/controllers_logs_list_test.go +++ b/internal/api/v1/controllers_logs_list_test.go @@ -2,7 +2,7 @@ package v1 import ( "encoding/json" - "github.com/formancehq/go-libs/v2/pointer" + "github.com/formancehq/go-libs/v3/pointer" "github.com/formancehq/ledger/internal/api/common" storagecommon "github.com/formancehq/ledger/internal/storage/common" "net/http" @@ -11,11 +11,11 @@ import ( "os" "testing" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/auth" - "github.com/formancehq/go-libs/v2/bun/bunpaginate" - "github.com/formancehq/go-libs/v2/query" - "github.com/formancehq/go-libs/v2/time" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/auth" + "github.com/formancehq/go-libs/v3/bun/bunpaginate" + "github.com/formancehq/go-libs/v3/query" + "github.com/formancehq/go-libs/v3/time" ledger "github.com/formancehq/ledger/internal" "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" diff --git a/internal/api/v1/controllers_stats.go b/internal/api/v1/controllers_stats.go index ddda7b7f33..72519956be 100644 --- a/internal/api/v1/controllers_stats.go +++ b/internal/api/v1/controllers_stats.go @@ -3,7 +3,7 @@ package v1 import ( "net/http" - "github.com/formancehq/go-libs/v2/api" + "github.com/formancehq/go-libs/v3/api" "github.com/formancehq/ledger/internal/api/common" ) diff --git a/internal/api/v1/controllers_stats_test.go b/internal/api/v1/controllers_stats_test.go index 91bb2958a0..596eb06a09 100644 --- a/internal/api/v1/controllers_stats_test.go +++ b/internal/api/v1/controllers_stats_test.go @@ -6,8 +6,8 @@ import ( "os" "testing" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/auth" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/auth" ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" diff --git a/internal/api/v1/controllers_transactions.go b/internal/api/v1/controllers_transactions.go index 86d712dc02..879408e54b 100644 --- a/internal/api/v1/controllers_transactions.go +++ b/internal/api/v1/controllers_transactions.go @@ -5,7 +5,7 @@ import ( "net/http" "strings" - "github.com/formancehq/go-libs/v2/query" + "github.com/formancehq/go-libs/v3/query" ledger "github.com/formancehq/ledger/internal" ) diff --git a/internal/api/v1/controllers_transactions_add_metadata.go b/internal/api/v1/controllers_transactions_add_metadata.go index 50e3142d9c..5ffedd58c9 100644 --- a/internal/api/v1/controllers_transactions_add_metadata.go +++ b/internal/api/v1/controllers_transactions_add_metadata.go @@ -8,8 +8,8 @@ import ( ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" "errors" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/metadata" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/metadata" "github.com/formancehq/ledger/internal/api/common" "github.com/go-chi/chi/v5" ) diff --git a/internal/api/v1/controllers_transactions_add_metadata_test.go b/internal/api/v1/controllers_transactions_add_metadata_test.go index f33a311dc4..aec28c2d56 100644 --- a/internal/api/v1/controllers_transactions_add_metadata_test.go +++ b/internal/api/v1/controllers_transactions_add_metadata_test.go @@ -9,9 +9,9 @@ import ( "os" "testing" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/auth" - "github.com/formancehq/go-libs/v2/metadata" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/auth" + "github.com/formancehq/go-libs/v3/metadata" ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" diff --git a/internal/api/v1/controllers_transactions_count.go b/internal/api/v1/controllers_transactions_count.go index d67ec9f011..0f1bc91927 100644 --- a/internal/api/v1/controllers_transactions_count.go +++ b/internal/api/v1/controllers_transactions_count.go @@ -4,7 +4,7 @@ import ( "fmt" "net/http" - "github.com/formancehq/go-libs/v2/api" + "github.com/formancehq/go-libs/v3/api" "github.com/formancehq/ledger/internal/api/common" ) diff --git a/internal/api/v1/controllers_transactions_count_test.go b/internal/api/v1/controllers_transactions_count_test.go index 4d5a9b1817..d40251b20e 100644 --- a/internal/api/v1/controllers_transactions_count_test.go +++ b/internal/api/v1/controllers_transactions_count_test.go @@ -8,10 +8,10 @@ import ( "os" "testing" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/auth" - "github.com/formancehq/go-libs/v2/query" - "github.com/formancehq/go-libs/v2/time" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/auth" + "github.com/formancehq/go-libs/v3/query" + "github.com/formancehq/go-libs/v3/time" "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" ) diff --git a/internal/api/v1/controllers_transactions_create.go b/internal/api/v1/controllers_transactions_create.go index 3dea82a772..115459f1e5 100644 --- a/internal/api/v1/controllers_transactions_create.go +++ b/internal/api/v1/controllers_transactions_create.go @@ -9,9 +9,9 @@ import ( ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" "errors" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/metadata" - "github.com/formancehq/go-libs/v2/time" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/metadata" + "github.com/formancehq/go-libs/v3/time" ledger "github.com/formancehq/ledger/internal" "github.com/formancehq/ledger/internal/api/common" ) diff --git a/internal/api/v1/controllers_transactions_create_test.go b/internal/api/v1/controllers_transactions_create_test.go index a800cda5dd..9352ab0b4d 100644 --- a/internal/api/v1/controllers_transactions_create_test.go +++ b/internal/api/v1/controllers_transactions_create_test.go @@ -2,7 +2,7 @@ package v1 import ( "encoding/json" - "github.com/formancehq/go-libs/v2/pointer" + "github.com/formancehq/go-libs/v3/pointer" "github.com/formancehq/ledger/internal/api/common" "math/big" "net/http" @@ -11,10 +11,10 @@ import ( "os" "testing" - "github.com/formancehq/go-libs/v2/time" + "github.com/formancehq/go-libs/v3/time" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/auth" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/auth" ledger "github.com/formancehq/ledger/internal" ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" "github.com/stretchr/testify/require" diff --git a/internal/api/v1/controllers_transactions_delete_metadata.go b/internal/api/v1/controllers_transactions_delete_metadata.go index e2a017e7b7..5d9778f38d 100644 --- a/internal/api/v1/controllers_transactions_delete_metadata.go +++ b/internal/api/v1/controllers_transactions_delete_metadata.go @@ -7,7 +7,7 @@ import ( ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" "errors" - "github.com/formancehq/go-libs/v2/api" + "github.com/formancehq/go-libs/v3/api" "github.com/formancehq/ledger/internal/api/common" "github.com/go-chi/chi/v5" ) diff --git a/internal/api/v1/controllers_transactions_delete_metadata_test.go b/internal/api/v1/controllers_transactions_delete_metadata_test.go index ae3fc6eb3b..847476f511 100644 --- a/internal/api/v1/controllers_transactions_delete_metadata_test.go +++ b/internal/api/v1/controllers_transactions_delete_metadata_test.go @@ -10,9 +10,9 @@ import ( "testing" "errors" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/auth" - "github.com/formancehq/go-libs/v2/logging" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/auth" + "github.com/formancehq/go-libs/v3/logging" ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" diff --git a/internal/api/v1/controllers_transactions_list.go b/internal/api/v1/controllers_transactions_list.go index bf575cb8c3..1936fdc01e 100644 --- a/internal/api/v1/controllers_transactions_list.go +++ b/internal/api/v1/controllers_transactions_list.go @@ -3,8 +3,8 @@ package v1 import ( "net/http" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/bun/bunpaginate" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/bun/bunpaginate" "github.com/formancehq/ledger/internal/api/common" ) diff --git a/internal/api/v1/controllers_transactions_list_test.go b/internal/api/v1/controllers_transactions_list_test.go index 8cc2fb9eef..9b4287a356 100644 --- a/internal/api/v1/controllers_transactions_list_test.go +++ b/internal/api/v1/controllers_transactions_list_test.go @@ -1,7 +1,7 @@ package v1 import ( - "github.com/formancehq/go-libs/v2/pointer" + "github.com/formancehq/go-libs/v3/pointer" "github.com/formancehq/ledger/internal/api/common" storagecommon "github.com/formancehq/ledger/internal/storage/common" "math/big" @@ -11,11 +11,11 @@ import ( "os" "testing" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/auth" - "github.com/formancehq/go-libs/v2/bun/bunpaginate" - "github.com/formancehq/go-libs/v2/query" - "github.com/formancehq/go-libs/v2/time" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/auth" + "github.com/formancehq/go-libs/v3/bun/bunpaginate" + "github.com/formancehq/go-libs/v3/query" + "github.com/formancehq/go-libs/v3/time" ledger "github.com/formancehq/ledger/internal" "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" diff --git a/internal/api/v1/controllers_transactions_read.go b/internal/api/v1/controllers_transactions_read.go index b2102ed884..f07715186b 100644 --- a/internal/api/v1/controllers_transactions_read.go +++ b/internal/api/v1/controllers_transactions_read.go @@ -1,12 +1,12 @@ package v1 import ( - "github.com/formancehq/go-libs/v2/query" + "github.com/formancehq/go-libs/v3/query" "net/http" "strconv" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/platform/postgres" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/platform/postgres" "github.com/formancehq/ledger/internal/api/common" "github.com/go-chi/chi/v5" ) diff --git a/internal/api/v1/controllers_transactions_read_test.go b/internal/api/v1/controllers_transactions_read_test.go index 1196127f1a..8673d0ffd7 100644 --- a/internal/api/v1/controllers_transactions_read_test.go +++ b/internal/api/v1/controllers_transactions_read_test.go @@ -1,7 +1,7 @@ package v1 import ( - "github.com/formancehq/go-libs/v2/query" + "github.com/formancehq/go-libs/v3/query" storagecommon "github.com/formancehq/ledger/internal/storage/common" "math/big" "net/http" @@ -9,8 +9,8 @@ import ( "os" "testing" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/auth" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/auth" ledger "github.com/formancehq/ledger/internal" "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" diff --git a/internal/api/v1/controllers_transactions_revert.go b/internal/api/v1/controllers_transactions_revert.go index fa294862c2..f0cc1dfcd8 100644 --- a/internal/api/v1/controllers_transactions_revert.go +++ b/internal/api/v1/controllers_transactions_revert.go @@ -7,7 +7,7 @@ import ( ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" "errors" - "github.com/formancehq/go-libs/v2/api" + "github.com/formancehq/go-libs/v3/api" "github.com/formancehq/ledger/internal/api/common" "github.com/go-chi/chi/v5" ) diff --git a/internal/api/v1/controllers_transactions_revert_test.go b/internal/api/v1/controllers_transactions_revert_test.go index cf97b1a680..eddc24cc0d 100644 --- a/internal/api/v1/controllers_transactions_revert_test.go +++ b/internal/api/v1/controllers_transactions_revert_test.go @@ -9,9 +9,9 @@ import ( "os" "testing" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/auth" - "github.com/formancehq/go-libs/v2/pointer" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/auth" + "github.com/formancehq/go-libs/v3/pointer" ledger "github.com/formancehq/ledger/internal" ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" "github.com/stretchr/testify/require" diff --git a/internal/api/v1/middleware_auto_create_ledger.go b/internal/api/v1/middleware_auto_create_ledger.go index 0bf4cf89d9..109e72b76d 100644 --- a/internal/api/v1/middleware_auto_create_ledger.go +++ b/internal/api/v1/middleware_auto_create_ledger.go @@ -9,10 +9,10 @@ import ( "github.com/formancehq/ledger/internal/controller/system" - "github.com/formancehq/go-libs/v2/platform/postgres" + "github.com/formancehq/go-libs/v3/platform/postgres" ledger "github.com/formancehq/ledger/internal" - "github.com/formancehq/go-libs/v2/api" + "github.com/formancehq/go-libs/v3/api" "github.com/go-chi/chi/v5" ) diff --git a/internal/api/v1/mocks_ledger_controller_test.go b/internal/api/v1/mocks_ledger_controller_test.go index a88cda1b20..8b51bccd66 100644 --- a/internal/api/v1/mocks_ledger_controller_test.go +++ b/internal/api/v1/mocks_ledger_controller_test.go @@ -12,8 +12,8 @@ import ( sql "database/sql" reflect "reflect" - bunpaginate "github.com/formancehq/go-libs/v2/bun/bunpaginate" - migrations "github.com/formancehq/go-libs/v2/migrations" + bunpaginate "github.com/formancehq/go-libs/v3/bun/bunpaginate" + migrations "github.com/formancehq/go-libs/v3/migrations" ledger "github.com/formancehq/ledger/internal" ledger0 "github.com/formancehq/ledger/internal/controller/ledger" common "github.com/formancehq/ledger/internal/storage/common" diff --git a/internal/api/v1/mocks_system_controller_test.go b/internal/api/v1/mocks_system_controller_test.go index 339ef4e281..cc772b5eec 100644 --- a/internal/api/v1/mocks_system_controller_test.go +++ b/internal/api/v1/mocks_system_controller_test.go @@ -11,7 +11,7 @@ import ( context "context" reflect "reflect" - bunpaginate "github.com/formancehq/go-libs/v2/bun/bunpaginate" + bunpaginate "github.com/formancehq/go-libs/v3/bun/bunpaginate" ledger "github.com/formancehq/ledger/internal" ledger0 "github.com/formancehq/ledger/internal/controller/ledger" common "github.com/formancehq/ledger/internal/storage/common" diff --git a/internal/api/v1/routes.go b/internal/api/v1/routes.go index 022a61bda2..2b6d28fdbf 100644 --- a/internal/api/v1/routes.go +++ b/internal/api/v1/routes.go @@ -7,7 +7,7 @@ import ( "github.com/formancehq/ledger/internal/controller/system" - "github.com/formancehq/go-libs/v2/auth" + "github.com/formancehq/go-libs/v3/auth" "github.com/formancehq/ledger/internal/api/common" "github.com/go-chi/chi/v5" ) diff --git a/internal/api/v1/utils.go b/internal/api/v1/utils.go index 5ad74e9978..455d12402d 100644 --- a/internal/api/v1/utils.go +++ b/internal/api/v1/utils.go @@ -7,9 +7,9 @@ import ( ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" - "github.com/formancehq/go-libs/v2/bun/bunpaginate" + "github.com/formancehq/go-libs/v3/bun/bunpaginate" - "github.com/formancehq/go-libs/v2/pointer" + "github.com/formancehq/go-libs/v3/pointer" ) func getCommandParameters[INPUT any](r *http.Request, input INPUT) ledgercontroller.Parameters[INPUT] { diff --git a/internal/api/v2/common.go b/internal/api/v2/common.go index 0b5dd13b6d..6824a6ce12 100644 --- a/internal/api/v2/common.go +++ b/internal/api/v2/common.go @@ -1,18 +1,18 @@ package v2 import ( - . "github.com/formancehq/go-libs/v2/collectionutils" + . "github.com/formancehq/go-libs/v3/collectionutils" "github.com/formancehq/ledger/internal/api/common" storagecommon "github.com/formancehq/ledger/internal/storage/common" "io" "net/http" "strings" - "github.com/formancehq/go-libs/v2/bun/bunpaginate" - "github.com/formancehq/go-libs/v2/time" + "github.com/formancehq/go-libs/v3/bun/bunpaginate" + "github.com/formancehq/go-libs/v3/time" - "github.com/formancehq/go-libs/v2/pointer" - "github.com/formancehq/go-libs/v2/query" + "github.com/formancehq/go-libs/v3/pointer" + "github.com/formancehq/go-libs/v3/query" ) func getDate(r *http.Request, key string) (*time.Time, error) { diff --git a/internal/api/v2/controllers_accounts_add_metadata.go b/internal/api/v2/controllers_accounts_add_metadata.go index 5f1a28d213..18070b6823 100644 --- a/internal/api/v2/controllers_accounts_add_metadata.go +++ b/internal/api/v2/controllers_accounts_add_metadata.go @@ -7,8 +7,8 @@ import ( "net/url" "errors" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/metadata" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/metadata" "github.com/formancehq/ledger/internal/api/common" "github.com/go-chi/chi/v5" ) diff --git a/internal/api/v2/controllers_accounts_add_metadata_test.go b/internal/api/v2/controllers_accounts_add_metadata_test.go index 9dfb4927c9..c41a89c142 100644 --- a/internal/api/v2/controllers_accounts_add_metadata_test.go +++ b/internal/api/v2/controllers_accounts_add_metadata_test.go @@ -10,9 +10,9 @@ import ( ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/auth" - "github.com/formancehq/go-libs/v2/metadata" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/auth" + "github.com/formancehq/go-libs/v3/metadata" "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" ) diff --git a/internal/api/v2/controllers_accounts_count.go b/internal/api/v2/controllers_accounts_count.go index c968902d52..90dee23237 100644 --- a/internal/api/v2/controllers_accounts_count.go +++ b/internal/api/v2/controllers_accounts_count.go @@ -6,7 +6,7 @@ import ( "net/http" "errors" - "github.com/formancehq/go-libs/v2/api" + "github.com/formancehq/go-libs/v3/api" "github.com/formancehq/ledger/internal/api/common" ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" ) diff --git a/internal/api/v2/controllers_accounts_count_test.go b/internal/api/v2/controllers_accounts_count_test.go index a29a381215..6fb120aaee 100644 --- a/internal/api/v2/controllers_accounts_count_test.go +++ b/internal/api/v2/controllers_accounts_count_test.go @@ -10,10 +10,10 @@ import ( "testing" "errors" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/auth" - "github.com/formancehq/go-libs/v2/query" - "github.com/formancehq/go-libs/v2/time" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/auth" + "github.com/formancehq/go-libs/v3/query" + "github.com/formancehq/go-libs/v3/time" ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" diff --git a/internal/api/v2/controllers_accounts_delete_metadata.go b/internal/api/v2/controllers_accounts_delete_metadata.go index 26775a7d5c..17f568701c 100644 --- a/internal/api/v2/controllers_accounts_delete_metadata.go +++ b/internal/api/v2/controllers_accounts_delete_metadata.go @@ -7,7 +7,7 @@ import ( "github.com/go-chi/chi/v5" - "github.com/formancehq/go-libs/v2/api" + "github.com/formancehq/go-libs/v3/api" "github.com/formancehq/ledger/internal/api/common" ) diff --git a/internal/api/v2/controllers_accounts_delete_metadata_test.go b/internal/api/v2/controllers_accounts_delete_metadata_test.go index 63eb33e593..3d004611b1 100644 --- a/internal/api/v2/controllers_accounts_delete_metadata_test.go +++ b/internal/api/v2/controllers_accounts_delete_metadata_test.go @@ -10,9 +10,9 @@ import ( "testing" "errors" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/auth" - "github.com/formancehq/go-libs/v2/logging" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/auth" + "github.com/formancehq/go-libs/v3/logging" ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" diff --git a/internal/api/v2/controllers_accounts_list.go b/internal/api/v2/controllers_accounts_list.go index 34f53eed9f..209660f88b 100644 --- a/internal/api/v2/controllers_accounts_list.go +++ b/internal/api/v2/controllers_accounts_list.go @@ -2,7 +2,7 @@ package v2 import ( "errors" - "github.com/formancehq/go-libs/v2/api" + "github.com/formancehq/go-libs/v3/api" "github.com/formancehq/ledger/internal/api/common" ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" storagecommon "github.com/formancehq/ledger/internal/storage/common" diff --git a/internal/api/v2/controllers_accounts_list_test.go b/internal/api/v2/controllers_accounts_list_test.go index 49322362af..c257b911b0 100644 --- a/internal/api/v2/controllers_accounts_list_test.go +++ b/internal/api/v2/controllers_accounts_list_test.go @@ -10,12 +10,12 @@ import ( "testing" "errors" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/auth" - "github.com/formancehq/go-libs/v2/bun/bunpaginate" - "github.com/formancehq/go-libs/v2/metadata" - "github.com/formancehq/go-libs/v2/query" - "github.com/formancehq/go-libs/v2/time" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/auth" + "github.com/formancehq/go-libs/v3/bun/bunpaginate" + "github.com/formancehq/go-libs/v3/metadata" + "github.com/formancehq/go-libs/v3/query" + "github.com/formancehq/go-libs/v3/time" ledger "github.com/formancehq/ledger/internal" ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" "github.com/stretchr/testify/require" diff --git a/internal/api/v2/controllers_accounts_read.go b/internal/api/v2/controllers_accounts_read.go index af1ba4d29e..c963bda01b 100644 --- a/internal/api/v2/controllers_accounts_read.go +++ b/internal/api/v2/controllers_accounts_read.go @@ -1,13 +1,13 @@ package v2 import ( - "github.com/formancehq/go-libs/v2/query" + "github.com/formancehq/go-libs/v3/query" storagecommon "github.com/formancehq/ledger/internal/storage/common" "net/http" "net/url" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/platform/postgres" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/platform/postgres" "github.com/formancehq/ledger/internal/api/common" "github.com/go-chi/chi/v5" ) diff --git a/internal/api/v2/controllers_accounts_read_test.go b/internal/api/v2/controllers_accounts_read_test.go index 03a45aeae5..336f7e376b 100644 --- a/internal/api/v2/controllers_accounts_read_test.go +++ b/internal/api/v2/controllers_accounts_read_test.go @@ -2,7 +2,7 @@ package v2 import ( "bytes" - "github.com/formancehq/go-libs/v2/query" + "github.com/formancehq/go-libs/v3/query" "github.com/formancehq/ledger/internal/api/common" storagecommon "github.com/formancehq/ledger/internal/storage/common" "net/http" @@ -10,9 +10,9 @@ import ( "net/url" "testing" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/auth" - "github.com/formancehq/go-libs/v2/time" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/auth" + "github.com/formancehq/go-libs/v3/time" ledger "github.com/formancehq/ledger/internal" "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" diff --git a/internal/api/v2/controllers_balances.go b/internal/api/v2/controllers_balances.go index dd9883c8fc..a39765cf2f 100644 --- a/internal/api/v2/controllers_balances.go +++ b/internal/api/v2/controllers_balances.go @@ -7,7 +7,7 @@ import ( "errors" ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" - "github.com/formancehq/go-libs/v2/api" + "github.com/formancehq/go-libs/v3/api" "github.com/formancehq/ledger/internal/api/common" ) diff --git a/internal/api/v2/controllers_balances_test.go b/internal/api/v2/controllers_balances_test.go index eef05fda9d..08d69ad72b 100644 --- a/internal/api/v2/controllers_balances_test.go +++ b/internal/api/v2/controllers_balances_test.go @@ -11,11 +11,11 @@ import ( ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" - "github.com/formancehq/go-libs/v2/time" + "github.com/formancehq/go-libs/v3/time" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/auth" - "github.com/formancehq/go-libs/v2/query" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/auth" + "github.com/formancehq/go-libs/v3/query" ledger "github.com/formancehq/ledger/internal" "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" diff --git a/internal/api/v2/controllers_bulk.go b/internal/api/v2/controllers_bulk.go index a34d454c97..2d26009e39 100644 --- a/internal/api/v2/controllers_bulk.go +++ b/internal/api/v2/controllers_bulk.go @@ -6,7 +6,7 @@ import ( "net/http" "strings" - "github.com/formancehq/go-libs/v2/api" + "github.com/formancehq/go-libs/v3/api" "github.com/formancehq/ledger/internal/api/common" ) diff --git a/internal/api/v2/controllers_bulk_test.go b/internal/api/v2/controllers_bulk_test.go index 0dc01a6b9f..bf1deba0ec 100644 --- a/internal/api/v2/controllers_bulk_test.go +++ b/internal/api/v2/controllers_bulk_test.go @@ -3,7 +3,7 @@ package v2 import ( "bytes" "fmt" - "github.com/formancehq/go-libs/v2/pointer" + "github.com/formancehq/go-libs/v3/pointer" "github.com/formancehq/ledger/internal/api/bulking" "github.com/uptrace/bun" "math/big" @@ -12,15 +12,15 @@ import ( "net/url" "testing" - "github.com/formancehq/go-libs/v2/collectionutils" + "github.com/formancehq/go-libs/v3/collectionutils" ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" - "github.com/formancehq/go-libs/v2/time" + "github.com/formancehq/go-libs/v3/time" "errors" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/auth" - "github.com/formancehq/go-libs/v2/metadata" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/auth" + "github.com/formancehq/go-libs/v3/metadata" ledger "github.com/formancehq/ledger/internal" "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" diff --git a/internal/api/v2/controllers_ledgers_create.go b/internal/api/v2/controllers_ledgers_create.go index 07e584c1cc..ac1ea9b2f3 100644 --- a/internal/api/v2/controllers_ledgers_create.go +++ b/internal/api/v2/controllers_ledgers_create.go @@ -11,7 +11,7 @@ import ( ledger "github.com/formancehq/ledger/internal" "errors" - "github.com/formancehq/go-libs/v2/api" + "github.com/formancehq/go-libs/v3/api" "github.com/go-chi/chi/v5" ) diff --git a/internal/api/v2/controllers_ledgers_create_test.go b/internal/api/v2/controllers_ledgers_create_test.go index 215060cab3..538770f8be 100644 --- a/internal/api/v2/controllers_ledgers_create_test.go +++ b/internal/api/v2/controllers_ledgers_create_test.go @@ -11,11 +11,11 @@ import ( "github.com/formancehq/ledger/internal/controller/system" "errors" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/logging" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/logging" ledger "github.com/formancehq/ledger/internal" - "github.com/formancehq/go-libs/v2/auth" + "github.com/formancehq/go-libs/v3/auth" "github.com/google/uuid" "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" diff --git a/internal/api/v2/controllers_ledgers_delete_metadata.go b/internal/api/v2/controllers_ledgers_delete_metadata.go index 060f7861bb..32cf4804a0 100644 --- a/internal/api/v2/controllers_ledgers_delete_metadata.go +++ b/internal/api/v2/controllers_ledgers_delete_metadata.go @@ -6,7 +6,7 @@ import ( "github.com/formancehq/ledger/internal/controller/system" - "github.com/formancehq/go-libs/v2/api" + "github.com/formancehq/go-libs/v3/api" "github.com/go-chi/chi/v5" ) diff --git a/internal/api/v2/controllers_ledgers_delete_metadata_test.go b/internal/api/v2/controllers_ledgers_delete_metadata_test.go index 8ac347f1e5..35885d6a5e 100644 --- a/internal/api/v2/controllers_ledgers_delete_metadata_test.go +++ b/internal/api/v2/controllers_ledgers_delete_metadata_test.go @@ -7,10 +7,10 @@ import ( "testing" "errors" - "github.com/formancehq/go-libs/v2/api" + "github.com/formancehq/go-libs/v3/api" - "github.com/formancehq/go-libs/v2/auth" - "github.com/formancehq/go-libs/v2/logging" + "github.com/formancehq/go-libs/v3/auth" + "github.com/formancehq/go-libs/v3/logging" "github.com/google/uuid" "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" diff --git a/internal/api/v2/controllers_ledgers_info.go b/internal/api/v2/controllers_ledgers_info.go index 688c81da02..f1189a9722 100644 --- a/internal/api/v2/controllers_ledgers_info.go +++ b/internal/api/v2/controllers_ledgers_info.go @@ -5,8 +5,8 @@ import ( "github.com/go-chi/chi/v5" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/migrations" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/migrations" "github.com/formancehq/ledger/internal/api/common" ) diff --git a/internal/api/v2/controllers_ledgers_info_test.go b/internal/api/v2/controllers_ledgers_info_test.go index c7c0d0963e..44a03bcba6 100644 --- a/internal/api/v2/controllers_ledgers_info_test.go +++ b/internal/api/v2/controllers_ledgers_info_test.go @@ -5,11 +5,11 @@ import ( "net/http/httptest" "testing" - "github.com/formancehq/go-libs/v2/time" + "github.com/formancehq/go-libs/v3/time" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/auth" - "github.com/formancehq/go-libs/v2/migrations" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/auth" + "github.com/formancehq/go-libs/v3/migrations" "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" ) diff --git a/internal/api/v2/controllers_ledgers_list.go b/internal/api/v2/controllers_ledgers_list.go index 436926aff1..2179e913d5 100644 --- a/internal/api/v2/controllers_ledgers_list.go +++ b/internal/api/v2/controllers_ledgers_list.go @@ -6,8 +6,8 @@ import ( "net/http" "errors" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/bun/bunpaginate" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/bun/bunpaginate" ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" "github.com/formancehq/ledger/internal/controller/system" ) diff --git a/internal/api/v2/controllers_ledgers_list_test.go b/internal/api/v2/controllers_ledgers_list_test.go index 11fd6ef0b7..449a4974e2 100644 --- a/internal/api/v2/controllers_ledgers_list_test.go +++ b/internal/api/v2/controllers_ledgers_list_test.go @@ -10,10 +10,10 @@ import ( "testing" "errors" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/auth" - "github.com/formancehq/go-libs/v2/bun/bunpaginate" - "github.com/formancehq/go-libs/v2/logging" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/auth" + "github.com/formancehq/go-libs/v3/bun/bunpaginate" + "github.com/formancehq/go-libs/v3/logging" ledger "github.com/formancehq/ledger/internal" ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" "github.com/google/uuid" diff --git a/internal/api/v2/controllers_ledgers_read.go b/internal/api/v2/controllers_ledgers_read.go index 59d94e7b14..e4dd69e1b1 100644 --- a/internal/api/v2/controllers_ledgers_read.go +++ b/internal/api/v2/controllers_ledgers_read.go @@ -6,9 +6,9 @@ import ( "github.com/formancehq/ledger/internal/controller/system" - "github.com/formancehq/go-libs/v2/platform/postgres" + "github.com/formancehq/go-libs/v3/platform/postgres" - "github.com/formancehq/go-libs/v2/api" + "github.com/formancehq/go-libs/v3/api" "github.com/go-chi/chi/v5" ) diff --git a/internal/api/v2/controllers_ledgers_read_test.go b/internal/api/v2/controllers_ledgers_read_test.go index 1ee21facb8..83f7a2a447 100644 --- a/internal/api/v2/controllers_ledgers_read_test.go +++ b/internal/api/v2/controllers_ledgers_read_test.go @@ -7,10 +7,10 @@ import ( ledger "github.com/formancehq/ledger/internal" - "github.com/formancehq/go-libs/v2/time" + "github.com/formancehq/go-libs/v3/time" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/auth" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/auth" "github.com/google/uuid" "github.com/stretchr/testify/require" diff --git a/internal/api/v2/controllers_ledgers_update_metadata.go b/internal/api/v2/controllers_ledgers_update_metadata.go index c18cd2e907..8f95ae443f 100644 --- a/internal/api/v2/controllers_ledgers_update_metadata.go +++ b/internal/api/v2/controllers_ledgers_update_metadata.go @@ -6,8 +6,8 @@ import ( "net/http" "errors" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/metadata" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/metadata" systemcontroller "github.com/formancehq/ledger/internal/controller/system" "github.com/go-chi/chi/v5" ) diff --git a/internal/api/v2/controllers_ledgers_update_metadata_test.go b/internal/api/v2/controllers_ledgers_update_metadata_test.go index 7741977948..b1217b32cb 100644 --- a/internal/api/v2/controllers_ledgers_update_metadata_test.go +++ b/internal/api/v2/controllers_ledgers_update_metadata_test.go @@ -5,9 +5,9 @@ import ( "net/http/httptest" "testing" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/auth" - "github.com/formancehq/go-libs/v2/logging" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/auth" + "github.com/formancehq/go-libs/v3/logging" "github.com/google/uuid" "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" diff --git a/internal/api/v2/controllers_logs_export_test.go b/internal/api/v2/controllers_logs_export_test.go index cf9cdebde5..6e78145d54 100644 --- a/internal/api/v2/controllers_logs_export_test.go +++ b/internal/api/v2/controllers_logs_export_test.go @@ -8,8 +8,8 @@ import ( "testing" "errors" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/auth" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/auth" ledger "github.com/formancehq/ledger/internal" ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" "github.com/stretchr/testify/require" diff --git a/internal/api/v2/controllers_logs_import.go b/internal/api/v2/controllers_logs_import.go index 0718acab2a..7a5c1b2fac 100644 --- a/internal/api/v2/controllers_logs_import.go +++ b/internal/api/v2/controllers_logs_import.go @@ -8,7 +8,7 @@ import ( ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" "errors" - "github.com/formancehq/go-libs/v2/api" + "github.com/formancehq/go-libs/v3/api" ledger "github.com/formancehq/ledger/internal" "github.com/formancehq/ledger/internal/api/common" ) diff --git a/internal/api/v2/controllers_logs_import_test.go b/internal/api/v2/controllers_logs_import_test.go index 1cb5d20d33..ed1d82967e 100644 --- a/internal/api/v2/controllers_logs_import_test.go +++ b/internal/api/v2/controllers_logs_import_test.go @@ -10,8 +10,8 @@ import ( "time" "errors" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/auth" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/auth" ledger "github.com/formancehq/ledger/internal" "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" diff --git a/internal/api/v2/controllers_logs_list.go b/internal/api/v2/controllers_logs_list.go index 24b60f5676..3bea0cec1b 100644 --- a/internal/api/v2/controllers_logs_list.go +++ b/internal/api/v2/controllers_logs_list.go @@ -2,8 +2,8 @@ package v2 import ( "errors" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/bun/bunpaginate" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/bun/bunpaginate" "github.com/formancehq/ledger/internal/api/common" storagecommon "github.com/formancehq/ledger/internal/storage/common" "net/http" diff --git a/internal/api/v2/controllers_logs_list_test.go b/internal/api/v2/controllers_logs_list_test.go index 9ae10e691a..1c3f2ea4a5 100644 --- a/internal/api/v2/controllers_logs_list_test.go +++ b/internal/api/v2/controllers_logs_list_test.go @@ -4,7 +4,7 @@ import ( "bytes" "encoding/json" "fmt" - "github.com/formancehq/go-libs/v2/pointer" + "github.com/formancehq/go-libs/v3/pointer" "github.com/formancehq/ledger/internal/api/common" storagecommon "github.com/formancehq/ledger/internal/storage/common" "net/http" @@ -13,11 +13,11 @@ import ( "testing" "errors" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/auth" - "github.com/formancehq/go-libs/v2/bun/bunpaginate" - "github.com/formancehq/go-libs/v2/query" - "github.com/formancehq/go-libs/v2/time" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/auth" + "github.com/formancehq/go-libs/v3/bun/bunpaginate" + "github.com/formancehq/go-libs/v3/query" + "github.com/formancehq/go-libs/v3/time" ledger "github.com/formancehq/ledger/internal" "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" diff --git a/internal/api/v2/controllers_stats.go b/internal/api/v2/controllers_stats.go index 569cd82f3f..1b57782252 100644 --- a/internal/api/v2/controllers_stats.go +++ b/internal/api/v2/controllers_stats.go @@ -3,7 +3,7 @@ package v2 import ( "net/http" - "github.com/formancehq/go-libs/v2/api" + "github.com/formancehq/go-libs/v3/api" "github.com/formancehq/ledger/internal/api/common" ) diff --git a/internal/api/v2/controllers_stats_test.go b/internal/api/v2/controllers_stats_test.go index fcc3cc287d..089b51327b 100644 --- a/internal/api/v2/controllers_stats_test.go +++ b/internal/api/v2/controllers_stats_test.go @@ -5,8 +5,8 @@ import ( "net/http/httptest" "testing" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/auth" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/auth" ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" diff --git a/internal/api/v2/controllers_transactions_add_metadata.go b/internal/api/v2/controllers_transactions_add_metadata.go index c64c4b9973..2bb5270857 100644 --- a/internal/api/v2/controllers_transactions_add_metadata.go +++ b/internal/api/v2/controllers_transactions_add_metadata.go @@ -8,8 +8,8 @@ import ( ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" "errors" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/metadata" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/metadata" "github.com/formancehq/ledger/internal/api/common" "github.com/go-chi/chi/v5" ) diff --git a/internal/api/v2/controllers_transactions_add_metadata_test.go b/internal/api/v2/controllers_transactions_add_metadata_test.go index 345be6f570..2dc90f2c2d 100644 --- a/internal/api/v2/controllers_transactions_add_metadata_test.go +++ b/internal/api/v2/controllers_transactions_add_metadata_test.go @@ -12,9 +12,9 @@ import ( ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/auth" - "github.com/formancehq/go-libs/v2/metadata" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/auth" + "github.com/formancehq/go-libs/v3/metadata" "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" ) diff --git a/internal/api/v2/controllers_transactions_count.go b/internal/api/v2/controllers_transactions_count.go index 3fc0a0db17..63a986466f 100644 --- a/internal/api/v2/controllers_transactions_count.go +++ b/internal/api/v2/controllers_transactions_count.go @@ -6,7 +6,7 @@ import ( "net/http" "errors" - "github.com/formancehq/go-libs/v2/api" + "github.com/formancehq/go-libs/v3/api" "github.com/formancehq/ledger/internal/api/common" ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" ) diff --git a/internal/api/v2/controllers_transactions_count_test.go b/internal/api/v2/controllers_transactions_count_test.go index 4c4f4f2134..e699a5b444 100644 --- a/internal/api/v2/controllers_transactions_count_test.go +++ b/internal/api/v2/controllers_transactions_count_test.go @@ -11,10 +11,10 @@ import ( "testing" "errors" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/auth" - "github.com/formancehq/go-libs/v2/query" - "github.com/formancehq/go-libs/v2/time" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/auth" + "github.com/formancehq/go-libs/v3/query" + "github.com/formancehq/go-libs/v3/time" ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" diff --git a/internal/api/v2/controllers_transactions_create.go b/internal/api/v2/controllers_transactions_create.go index 0bedd5517e..180871bfa0 100644 --- a/internal/api/v2/controllers_transactions_create.go +++ b/internal/api/v2/controllers_transactions_create.go @@ -9,7 +9,7 @@ import ( "errors" - "github.com/formancehq/go-libs/v2/api" + "github.com/formancehq/go-libs/v3/api" "github.com/formancehq/ledger/internal/api/common" ) diff --git a/internal/api/v2/controllers_transactions_create_test.go b/internal/api/v2/controllers_transactions_create_test.go index 7ae1108750..d0b89488e7 100644 --- a/internal/api/v2/controllers_transactions_create_test.go +++ b/internal/api/v2/controllers_transactions_create_test.go @@ -9,11 +9,11 @@ import ( "net/url" "testing" - "github.com/formancehq/go-libs/v2/time" + "github.com/formancehq/go-libs/v3/time" "errors" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/auth" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/auth" ledger "github.com/formancehq/ledger/internal" ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" "github.com/stretchr/testify/require" diff --git a/internal/api/v2/controllers_transactions_delete_metadata.go b/internal/api/v2/controllers_transactions_delete_metadata.go index 0628eedc7e..96fa25035c 100644 --- a/internal/api/v2/controllers_transactions_delete_metadata.go +++ b/internal/api/v2/controllers_transactions_delete_metadata.go @@ -11,7 +11,7 @@ import ( "errors" "github.com/formancehq/ledger/internal/api/common" - "github.com/formancehq/go-libs/v2/api" + "github.com/formancehq/go-libs/v3/api" ) func deleteTransactionMetadata(w http.ResponseWriter, r *http.Request) { diff --git a/internal/api/v2/controllers_transactions_delete_metadata_test.go b/internal/api/v2/controllers_transactions_delete_metadata_test.go index 05dcf8090f..1709f3579a 100644 --- a/internal/api/v2/controllers_transactions_delete_metadata_test.go +++ b/internal/api/v2/controllers_transactions_delete_metadata_test.go @@ -9,9 +9,9 @@ import ( "testing" "errors" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/auth" - "github.com/formancehq/go-libs/v2/logging" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/auth" + "github.com/formancehq/go-libs/v3/logging" ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" diff --git a/internal/api/v2/controllers_transactions_list.go b/internal/api/v2/controllers_transactions_list.go index 78ab817330..7587e2ca9c 100644 --- a/internal/api/v2/controllers_transactions_list.go +++ b/internal/api/v2/controllers_transactions_list.go @@ -2,8 +2,8 @@ package v2 import ( "errors" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/bun/bunpaginate" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/bun/bunpaginate" "github.com/formancehq/ledger/internal/api/common" ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" storagecommon "github.com/formancehq/ledger/internal/storage/common" diff --git a/internal/api/v2/controllers_transactions_list_test.go b/internal/api/v2/controllers_transactions_list_test.go index 46fb998090..7e189c3f29 100644 --- a/internal/api/v2/controllers_transactions_list_test.go +++ b/internal/api/v2/controllers_transactions_list_test.go @@ -3,7 +3,7 @@ package v2 import ( "bytes" "fmt" - "github.com/formancehq/go-libs/v2/pointer" + "github.com/formancehq/go-libs/v3/pointer" "github.com/formancehq/ledger/internal/api/common" storagecommon "github.com/formancehq/ledger/internal/storage/common" "math/big" @@ -12,11 +12,11 @@ import ( "net/url" "testing" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/auth" - "github.com/formancehq/go-libs/v2/bun/bunpaginate" - "github.com/formancehq/go-libs/v2/query" - "github.com/formancehq/go-libs/v2/time" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/auth" + "github.com/formancehq/go-libs/v3/bun/bunpaginate" + "github.com/formancehq/go-libs/v3/query" + "github.com/formancehq/go-libs/v3/time" ledger "github.com/formancehq/ledger/internal" "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" diff --git a/internal/api/v2/controllers_transactions_read.go b/internal/api/v2/controllers_transactions_read.go index 347b99665b..13cd81ce1e 100644 --- a/internal/api/v2/controllers_transactions_read.go +++ b/internal/api/v2/controllers_transactions_read.go @@ -1,13 +1,13 @@ package v2 import ( - "github.com/formancehq/go-libs/v2/query" + "github.com/formancehq/go-libs/v3/query" storagecommon "github.com/formancehq/ledger/internal/storage/common" "net/http" "strconv" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/platform/postgres" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/platform/postgres" "github.com/formancehq/ledger/internal/api/common" "github.com/go-chi/chi/v5" ) diff --git a/internal/api/v2/controllers_transactions_read_test.go b/internal/api/v2/controllers_transactions_read_test.go index 50b5c39ffc..b1f3bca620 100644 --- a/internal/api/v2/controllers_transactions_read_test.go +++ b/internal/api/v2/controllers_transactions_read_test.go @@ -1,16 +1,16 @@ package v2 import ( - "github.com/formancehq/go-libs/v2/query" + "github.com/formancehq/go-libs/v3/query" storagecommon "github.com/formancehq/ledger/internal/storage/common" "math/big" "net/http" "net/http/httptest" "testing" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/auth" - "github.com/formancehq/go-libs/v2/time" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/auth" + "github.com/formancehq/go-libs/v3/time" ledger "github.com/formancehq/ledger/internal" "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" diff --git a/internal/api/v2/controllers_transactions_revert.go b/internal/api/v2/controllers_transactions_revert.go index ebfe536fd3..9f2260085b 100644 --- a/internal/api/v2/controllers_transactions_revert.go +++ b/internal/api/v2/controllers_transactions_revert.go @@ -7,7 +7,7 @@ import ( ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" "errors" - "github.com/formancehq/go-libs/v2/api" + "github.com/formancehq/go-libs/v3/api" "github.com/formancehq/ledger/internal/api/common" "github.com/go-chi/chi/v5" ) diff --git a/internal/api/v2/controllers_transactions_revert_test.go b/internal/api/v2/controllers_transactions_revert_test.go index 253e3a9208..f55dbf1eac 100644 --- a/internal/api/v2/controllers_transactions_revert_test.go +++ b/internal/api/v2/controllers_transactions_revert_test.go @@ -8,8 +8,8 @@ import ( "net/url" "testing" - "github.com/formancehq/go-libs/v2/api" - "github.com/formancehq/go-libs/v2/auth" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/auth" ledger "github.com/formancehq/ledger/internal" ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" "github.com/stretchr/testify/require" diff --git a/internal/api/v2/controllers_volumes.go b/internal/api/v2/controllers_volumes.go index 554b593c24..cbf0741625 100644 --- a/internal/api/v2/controllers_volumes.go +++ b/internal/api/v2/controllers_volumes.go @@ -2,7 +2,7 @@ package v2 import ( "errors" - "github.com/formancehq/go-libs/v2/api" + "github.com/formancehq/go-libs/v3/api" "github.com/formancehq/ledger/internal/api/common" ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" storagecommon "github.com/formancehq/ledger/internal/storage/common" diff --git a/internal/api/v2/controllers_volumes_test.go b/internal/api/v2/controllers_volumes_test.go index 5b5f73e8ea..db6cd05033 100644 --- a/internal/api/v2/controllers_volumes_test.go +++ b/internal/api/v2/controllers_volumes_test.go @@ -12,14 +12,14 @@ import ( ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" - "github.com/formancehq/go-libs/v2/auth" - "github.com/formancehq/go-libs/v2/bun/bunpaginate" - "github.com/formancehq/go-libs/v2/time" + "github.com/formancehq/go-libs/v3/auth" + "github.com/formancehq/go-libs/v3/bun/bunpaginate" + "github.com/formancehq/go-libs/v3/time" - "github.com/formancehq/go-libs/v2/api" + "github.com/formancehq/go-libs/v3/api" ledger "github.com/formancehq/ledger/internal" - "github.com/formancehq/go-libs/v2/query" + "github.com/formancehq/go-libs/v3/query" "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" ) diff --git a/internal/api/v2/mocks_ledger_controller_test.go b/internal/api/v2/mocks_ledger_controller_test.go index b57db0c290..7fd14ccf2d 100644 --- a/internal/api/v2/mocks_ledger_controller_test.go +++ b/internal/api/v2/mocks_ledger_controller_test.go @@ -12,8 +12,8 @@ import ( sql "database/sql" reflect "reflect" - bunpaginate "github.com/formancehq/go-libs/v2/bun/bunpaginate" - migrations "github.com/formancehq/go-libs/v2/migrations" + bunpaginate "github.com/formancehq/go-libs/v3/bun/bunpaginate" + migrations "github.com/formancehq/go-libs/v3/migrations" ledger "github.com/formancehq/ledger/internal" ledger0 "github.com/formancehq/ledger/internal/controller/ledger" common "github.com/formancehq/ledger/internal/storage/common" diff --git a/internal/api/v2/mocks_system_controller_test.go b/internal/api/v2/mocks_system_controller_test.go index 0188838c7e..e5e596f0cf 100644 --- a/internal/api/v2/mocks_system_controller_test.go +++ b/internal/api/v2/mocks_system_controller_test.go @@ -11,7 +11,7 @@ import ( context "context" reflect "reflect" - bunpaginate "github.com/formancehq/go-libs/v2/bun/bunpaginate" + bunpaginate "github.com/formancehq/go-libs/v3/bun/bunpaginate" ledger "github.com/formancehq/ledger/internal" ledger0 "github.com/formancehq/ledger/internal/controller/ledger" common "github.com/formancehq/ledger/internal/storage/common" diff --git a/internal/api/v2/query.go b/internal/api/v2/query.go index 913231aafd..264fe762ce 100644 --- a/internal/api/v2/query.go +++ b/internal/api/v2/query.go @@ -5,7 +5,7 @@ import ( "github.com/formancehq/ledger/internal/controller/ledger" - "github.com/formancehq/go-libs/v2/api" + "github.com/formancehq/go-libs/v3/api" ) func getCommandParameters[INPUT any](r *http.Request, input INPUT) ledger.Parameters[INPUT] { diff --git a/internal/api/v2/routes.go b/internal/api/v2/routes.go index bbf354aac6..fa1380ccff 100644 --- a/internal/api/v2/routes.go +++ b/internal/api/v2/routes.go @@ -1,7 +1,7 @@ package v2 import ( - "github.com/formancehq/go-libs/v2/bun/bunpaginate" + "github.com/formancehq/go-libs/v3/bun/bunpaginate" "github.com/formancehq/ledger/internal/api/bulking" v1 "github.com/formancehq/ledger/internal/api/v1" nooptracer "go.opentelemetry.io/otel/trace/noop" @@ -12,7 +12,7 @@ import ( "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/trace" - "github.com/formancehq/go-libs/v2/auth" + "github.com/formancehq/go-libs/v3/auth" "github.com/formancehq/ledger/internal/api/common" "github.com/go-chi/chi/v5" ) @@ -130,7 +130,7 @@ func WithDefaultBulkHandlerFactories(bulkMaxSize int) RouterOption { return WithBulkHandlerFactories(map[string]bulking.HandlerFactory{ "application/json": bulking.NewJSONBulkHandlerFactory(bulkMaxSize), "application/vnd.formance.ledger.api.v2.bulk+script-stream": bulking.NewTextStreamBulkHandlerFactory(), - "application/vnd.formance.ledger.api.v2.bulk+json-stream": bulking.NewJSONStreamBulkHandlerFactory(), + "application/vnd.formance.ledger.api.v2.bulk+json-stream": bulking.NewJSONStreamBulkHandlerFactory(), }) } @@ -140,6 +140,6 @@ var defaultRouterOptions = []RouterOption{ WithDefaultBulkHandlerFactories(100), WithPaginationConfig(common.PaginationConfig{ DefaultPageSize: bunpaginate.QueryDefaultPageSize, - MaxPageSize: bunpaginate.MaxPageSize, + MaxPageSize: bunpaginate.MaxPageSize, }), } diff --git a/internal/bus/listener.go b/internal/bus/listener.go index 8fb268a6fc..1ed71b16d9 100644 --- a/internal/bus/listener.go +++ b/internal/bus/listener.go @@ -6,9 +6,9 @@ import ( ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" "github.com/ThreeDotsLabs/watermill/message" - "github.com/formancehq/go-libs/v2/logging" - "github.com/formancehq/go-libs/v2/metadata" - "github.com/formancehq/go-libs/v2/publish" + "github.com/formancehq/go-libs/v3/logging" + "github.com/formancehq/go-libs/v3/metadata" + "github.com/formancehq/go-libs/v3/publish" ledger "github.com/formancehq/ledger/internal" "github.com/formancehq/ledger/pkg/events" ) diff --git a/internal/bus/listener_test.go b/internal/bus/listener_test.go index aca4ecacc3..1c18608d80 100644 --- a/internal/bus/listener_test.go +++ b/internal/bus/listener_test.go @@ -10,7 +10,7 @@ import ( "github.com/ThreeDotsLabs/watermill" "github.com/ThreeDotsLabs/watermill/pubsub/gochannel" - topicmapper "github.com/formancehq/go-libs/v2/publish/topic_mapper" + topicmapper "github.com/formancehq/go-libs/v3/publish/topic_mapper" "github.com/pborman/uuid" "github.com/stretchr/testify/require" ) diff --git a/internal/bus/message.go b/internal/bus/message.go index a268c00de4..ff678856ff 100644 --- a/internal/bus/message.go +++ b/internal/bus/message.go @@ -1,9 +1,9 @@ package bus import ( - "github.com/formancehq/go-libs/v2/metadata" - "github.com/formancehq/go-libs/v2/publish" - "github.com/formancehq/go-libs/v2/time" + "github.com/formancehq/go-libs/v3/metadata" + "github.com/formancehq/go-libs/v3/publish" + "github.com/formancehq/go-libs/v3/time" ledger "github.com/formancehq/ledger/internal" "github.com/formancehq/ledger/pkg/events" ) diff --git a/internal/controller/ledger/controller.go b/internal/controller/ledger/controller.go index 1f96438b02..2c526721d2 100644 --- a/internal/controller/ledger/controller.go +++ b/internal/controller/ledger/controller.go @@ -3,13 +3,13 @@ package ledger import ( "context" "database/sql" - "github.com/formancehq/go-libs/v2/metadata" + "github.com/formancehq/go-libs/v3/metadata" "github.com/formancehq/ledger/internal/machine/vm" "github.com/formancehq/ledger/internal/storage/common" "github.com/uptrace/bun" - "github.com/formancehq/go-libs/v2/bun/bunpaginate" - "github.com/formancehq/go-libs/v2/migrations" + "github.com/formancehq/go-libs/v3/bun/bunpaginate" + "github.com/formancehq/go-libs/v3/migrations" ledger "github.com/formancehq/ledger/internal" ) diff --git a/internal/controller/ledger/controller_default.go b/internal/controller/ledger/controller_default.go index a4e504589e..cd5c783471 100644 --- a/internal/controller/ledger/controller_default.go +++ b/internal/controller/ledger/controller_default.go @@ -8,8 +8,8 @@ import ( "math/big" "reflect" - "github.com/formancehq/go-libs/v2/pointer" - "github.com/formancehq/go-libs/v2/time" + "github.com/formancehq/go-libs/v3/pointer" + "github.com/formancehq/go-libs/v3/time" "github.com/formancehq/ledger/pkg/features" "github.com/uptrace/bun" "go.opentelemetry.io/otel/metric" @@ -17,18 +17,18 @@ import ( "go.opentelemetry.io/otel/trace" nooptracer "go.opentelemetry.io/otel/trace/noop" - "github.com/formancehq/go-libs/v2/migrations" + "github.com/formancehq/go-libs/v3/migrations" "github.com/formancehq/ledger/internal/tracing" "github.com/formancehq/ledger/internal/machine" - "github.com/formancehq/go-libs/v2/platform/postgres" + "github.com/formancehq/go-libs/v3/platform/postgres" "errors" - "github.com/formancehq/go-libs/v2/bun/bunpaginate" - "github.com/formancehq/go-libs/v2/logging" - "github.com/formancehq/go-libs/v2/metadata" + "github.com/formancehq/go-libs/v3/bun/bunpaginate" + "github.com/formancehq/go-libs/v3/logging" + "github.com/formancehq/go-libs/v3/metadata" "github.com/google/uuid" ledger "github.com/formancehq/ledger/internal" diff --git a/internal/controller/ledger/controller_default_test.go b/internal/controller/ledger/controller_default_test.go index da9d004cf1..6ca375867b 100644 --- a/internal/controller/ledger/controller_default_test.go +++ b/internal/controller/ledger/controller_default_test.go @@ -2,20 +2,20 @@ package ledger import ( "context" - "github.com/formancehq/go-libs/v2/query" + "github.com/formancehq/go-libs/v3/query" "github.com/formancehq/ledger/internal/storage/common" "github.com/uptrace/bun" "math/big" "testing" - "github.com/formancehq/go-libs/v2/pointer" - "github.com/formancehq/go-libs/v2/time" + "github.com/formancehq/go-libs/v3/pointer" + "github.com/formancehq/go-libs/v3/time" - "github.com/formancehq/go-libs/v2/bun/bunpaginate" - "github.com/formancehq/go-libs/v2/migrations" + "github.com/formancehq/go-libs/v3/bun/bunpaginate" + "github.com/formancehq/go-libs/v3/migrations" - "github.com/formancehq/go-libs/v2/logging" - "github.com/formancehq/go-libs/v2/metadata" + "github.com/formancehq/go-libs/v3/logging" + "github.com/formancehq/go-libs/v3/metadata" ledger "github.com/formancehq/ledger/internal" "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" diff --git a/internal/controller/ledger/controller_generated_test.go b/internal/controller/ledger/controller_generated_test.go index d32c8d503f..3db866e593 100644 --- a/internal/controller/ledger/controller_generated_test.go +++ b/internal/controller/ledger/controller_generated_test.go @@ -12,8 +12,8 @@ import ( sql "database/sql" reflect "reflect" - bunpaginate "github.com/formancehq/go-libs/v2/bun/bunpaginate" - migrations "github.com/formancehq/go-libs/v2/migrations" + bunpaginate "github.com/formancehq/go-libs/v3/bun/bunpaginate" + migrations "github.com/formancehq/go-libs/v3/migrations" ledger "github.com/formancehq/ledger/internal" common "github.com/formancehq/ledger/internal/storage/common" bun "github.com/uptrace/bun" diff --git a/internal/controller/ledger/controller_with_too_many_client_handling.go b/internal/controller/ledger/controller_with_too_many_client_handling.go index f6858b2cdd..d0fa1dba5d 100644 --- a/internal/controller/ledger/controller_with_too_many_client_handling.go +++ b/internal/controller/ledger/controller_with_too_many_client_handling.go @@ -4,7 +4,7 @@ import ( "context" "database/sql" "errors" - "github.com/formancehq/go-libs/v2/platform/postgres" + "github.com/formancehq/go-libs/v3/platform/postgres" ledger "github.com/formancehq/ledger/internal" "github.com/uptrace/bun" "go.opentelemetry.io/otel/attribute" diff --git a/internal/controller/ledger/controller_with_too_many_client_handling_test.go b/internal/controller/ledger/controller_with_too_many_client_handling_test.go index b359317b5d..553b78a805 100644 --- a/internal/controller/ledger/controller_with_too_many_client_handling_test.go +++ b/internal/controller/ledger/controller_with_too_many_client_handling_test.go @@ -2,9 +2,9 @@ package ledger import ( "errors" - "github.com/formancehq/go-libs/v2/logging" - "github.com/formancehq/go-libs/v2/platform/postgres" - "github.com/formancehq/go-libs/v2/time" + "github.com/formancehq/go-libs/v3/logging" + "github.com/formancehq/go-libs/v3/platform/postgres" + "github.com/formancehq/go-libs/v3/time" ledger "github.com/formancehq/ledger/internal" "github.com/stretchr/testify/require" "go.opentelemetry.io/otel/trace/noop" diff --git a/internal/controller/ledger/controller_with_traces.go b/internal/controller/ledger/controller_with_traces.go index f48f2f549a..90c4f6a447 100644 --- a/internal/controller/ledger/controller_with_traces.go +++ b/internal/controller/ledger/controller_with_traces.go @@ -3,14 +3,14 @@ package ledger import ( "context" "database/sql" - "github.com/formancehq/go-libs/v2/migrations" + "github.com/formancehq/go-libs/v3/migrations" "github.com/formancehq/ledger/internal/storage/common" "github.com/formancehq/ledger/internal/tracing" "github.com/uptrace/bun" "go.opentelemetry.io/otel/metric" "go.opentelemetry.io/otel/trace" - "github.com/formancehq/go-libs/v2/bun/bunpaginate" + "github.com/formancehq/go-libs/v3/bun/bunpaginate" ledger "github.com/formancehq/ledger/internal" ) diff --git a/internal/controller/ledger/errors.go b/internal/controller/ledger/errors.go index 0011ed573e..ec6b2d5584 100644 --- a/internal/controller/ledger/errors.go +++ b/internal/controller/ledger/errors.go @@ -3,7 +3,7 @@ package ledger import ( "encoding/base64" "fmt" - "github.com/formancehq/go-libs/v2/platform/postgres" + "github.com/formancehq/go-libs/v3/platform/postgres" "github.com/formancehq/numscript" "github.com/formancehq/ledger/internal/machine" diff --git a/internal/controller/ledger/listener.go b/internal/controller/ledger/listener.go index 4a9a878e53..b8d6ec414a 100644 --- a/internal/controller/ledger/listener.go +++ b/internal/controller/ledger/listener.go @@ -3,7 +3,7 @@ package ledger import ( "context" - "github.com/formancehq/go-libs/v2/metadata" + "github.com/formancehq/go-libs/v3/metadata" ledger "github.com/formancehq/ledger/internal" ) diff --git a/internal/controller/ledger/listener_generated_test.go b/internal/controller/ledger/listener_generated_test.go index e0e7e584cf..21af13ebb3 100644 --- a/internal/controller/ledger/listener_generated_test.go +++ b/internal/controller/ledger/listener_generated_test.go @@ -11,7 +11,7 @@ import ( context "context" reflect "reflect" - metadata "github.com/formancehq/go-libs/v2/metadata" + metadata "github.com/formancehq/go-libs/v3/metadata" ledger "github.com/formancehq/ledger/internal" gomock "go.uber.org/mock/gomock" ) diff --git a/internal/controller/ledger/log_process.go b/internal/controller/ledger/log_process.go index 06d3667c65..baeabfa3a6 100644 --- a/internal/controller/ledger/log_process.go +++ b/internal/controller/ledger/log_process.go @@ -4,9 +4,9 @@ import ( "context" "errors" "fmt" - "github.com/formancehq/go-libs/v2/logging" - "github.com/formancehq/go-libs/v2/platform/postgres" - "github.com/formancehq/go-libs/v2/pointer" + "github.com/formancehq/go-libs/v3/logging" + "github.com/formancehq/go-libs/v3/platform/postgres" + "github.com/formancehq/go-libs/v3/pointer" ledger "github.com/formancehq/ledger/internal" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/metric" diff --git a/internal/controller/ledger/log_process_test.go b/internal/controller/ledger/log_process_test.go index a5d86ad259..832db6f954 100644 --- a/internal/controller/ledger/log_process_test.go +++ b/internal/controller/ledger/log_process_test.go @@ -2,9 +2,9 @@ package ledger import ( "context" - "github.com/formancehq/go-libs/v2/logging" - "github.com/formancehq/go-libs/v2/platform/postgres" - "github.com/formancehq/go-libs/v2/pointer" + "github.com/formancehq/go-libs/v3/logging" + "github.com/formancehq/go-libs/v3/platform/postgres" + "github.com/formancehq/go-libs/v3/pointer" ledger "github.com/formancehq/ledger/internal" "github.com/stretchr/testify/require" "github.com/uptrace/bun" diff --git a/internal/controller/ledger/mocks_test.go b/internal/controller/ledger/mocks_test.go index 12809d4e33..d1a0a6c764 100644 --- a/internal/controller/ledger/mocks_test.go +++ b/internal/controller/ledger/mocks_test.go @@ -11,7 +11,7 @@ import ( context "context" reflect "reflect" - bunpaginate "github.com/formancehq/go-libs/v2/bun/bunpaginate" + bunpaginate "github.com/formancehq/go-libs/v3/bun/bunpaginate" common "github.com/formancehq/ledger/internal/storage/common" bun "github.com/uptrace/bun" gomock "go.uber.org/mock/gomock" diff --git a/internal/controller/ledger/numscript.go b/internal/controller/ledger/numscript.go index 310166a844..b03ace3868 100644 --- a/internal/controller/ledger/numscript.go +++ b/internal/controller/ledger/numscript.go @@ -6,7 +6,7 @@ import ( "sort" "strings" - "github.com/formancehq/go-libs/v2/metadata" + "github.com/formancehq/go-libs/v3/metadata" ) type variable struct { diff --git a/internal/controller/ledger/numscript_runtime.go b/internal/controller/ledger/numscript_runtime.go index 930e274241..2577728846 100644 --- a/internal/controller/ledger/numscript_runtime.go +++ b/internal/controller/ledger/numscript_runtime.go @@ -6,8 +6,8 @@ import ( "errors" - "github.com/formancehq/go-libs/v2/collectionutils" - "github.com/formancehq/go-libs/v2/metadata" + "github.com/formancehq/go-libs/v3/collectionutils" + "github.com/formancehq/go-libs/v3/metadata" ledger "github.com/formancehq/ledger/internal" "github.com/formancehq/ledger/internal/machine" "github.com/formancehq/ledger/internal/machine/vm" diff --git a/internal/controller/ledger/stats_test.go b/internal/controller/ledger/stats_test.go index ab1062cfa1..1cf2f297a3 100644 --- a/internal/controller/ledger/stats_test.go +++ b/internal/controller/ledger/stats_test.go @@ -4,7 +4,7 @@ import ( "github.com/formancehq/ledger/internal/storage/common" "testing" - "github.com/formancehq/go-libs/v2/logging" + "github.com/formancehq/go-libs/v3/logging" ledger "github.com/formancehq/ledger/internal" "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" diff --git a/internal/controller/ledger/store.go b/internal/controller/ledger/store.go index 67b5e259b3..3468d7f4f8 100644 --- a/internal/controller/ledger/store.go +++ b/internal/controller/ledger/store.go @@ -3,17 +3,17 @@ package ledger import ( "context" "database/sql" - "github.com/formancehq/go-libs/v2/bun/bunpaginate" - "github.com/formancehq/go-libs/v2/pointer" + "github.com/formancehq/go-libs/v3/bun/bunpaginate" + "github.com/formancehq/go-libs/v3/pointer" "github.com/formancehq/ledger/internal/storage/common" "math/big" - "github.com/formancehq/go-libs/v2/migrations" + "github.com/formancehq/go-libs/v3/migrations" "github.com/formancehq/numscript" - "github.com/formancehq/go-libs/v2/metadata" - "github.com/formancehq/go-libs/v2/query" - "github.com/formancehq/go-libs/v2/time" + "github.com/formancehq/go-libs/v3/metadata" + "github.com/formancehq/go-libs/v3/query" + "github.com/formancehq/go-libs/v3/time" ledger "github.com/formancehq/ledger/internal" "github.com/formancehq/ledger/internal/machine/vm" "github.com/uptrace/bun" diff --git a/internal/controller/ledger/store_generated_test.go b/internal/controller/ledger/store_generated_test.go index 503047bc4e..2fb8c637ed 100644 --- a/internal/controller/ledger/store_generated_test.go +++ b/internal/controller/ledger/store_generated_test.go @@ -12,9 +12,9 @@ import ( sql "database/sql" reflect "reflect" - metadata "github.com/formancehq/go-libs/v2/metadata" - migrations "github.com/formancehq/go-libs/v2/migrations" - time "github.com/formancehq/go-libs/v2/time" + metadata "github.com/formancehq/go-libs/v3/metadata" + migrations "github.com/formancehq/go-libs/v3/migrations" + time "github.com/formancehq/go-libs/v3/time" ledger "github.com/formancehq/ledger/internal" common "github.com/formancehq/ledger/internal/storage/common" bun "github.com/uptrace/bun" diff --git a/internal/controller/system/controller.go b/internal/controller/system/controller.go index b45165adcd..619c19d3f1 100644 --- a/internal/controller/system/controller.go +++ b/internal/controller/system/controller.go @@ -15,7 +15,7 @@ import ( "github.com/formancehq/ledger/internal/tracing" - "github.com/formancehq/go-libs/v2/bun/bunpaginate" + "github.com/formancehq/go-libs/v3/bun/bunpaginate" ledger "github.com/formancehq/ledger/internal" ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" ) diff --git a/internal/controller/system/state_tracker.go b/internal/controller/system/state_tracker.go index b5e6ec61af..24b97af054 100644 --- a/internal/controller/system/state_tracker.go +++ b/internal/controller/system/state_tracker.go @@ -5,7 +5,7 @@ import ( "database/sql" "errors" "fmt" - "github.com/formancehq/go-libs/v2/logging" + "github.com/formancehq/go-libs/v3/logging" ledger "github.com/formancehq/ledger/internal" ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" ) diff --git a/internal/controller/system/store.go b/internal/controller/system/store.go index 5ea1031d56..f3cd1181fd 100644 --- a/internal/controller/system/store.go +++ b/internal/controller/system/store.go @@ -6,8 +6,8 @@ import ( ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" - "github.com/formancehq/go-libs/v2/bun/bunpaginate" - "github.com/formancehq/go-libs/v2/metadata" + "github.com/formancehq/go-libs/v3/bun/bunpaginate" + "github.com/formancehq/go-libs/v3/metadata" ledger "github.com/formancehq/ledger/internal" ) diff --git a/internal/ledger.go b/internal/ledger.go index 0fc01b64ff..f35d959979 100644 --- a/internal/ledger.go +++ b/internal/ledger.go @@ -2,8 +2,8 @@ package ledger import ( "fmt" - "github.com/formancehq/go-libs/v2/metadata" - "github.com/formancehq/go-libs/v2/time" + "github.com/formancehq/go-libs/v3/metadata" + "github.com/formancehq/go-libs/v3/time" "github.com/formancehq/ledger/pkg/features" "github.com/uptrace/bun" "regexp" diff --git a/internal/log.go b/internal/log.go index ac34aa1dc1..35c8621700 100644 --- a/internal/log.go +++ b/internal/log.go @@ -6,15 +6,15 @@ import ( "encoding/base64" "encoding/json" "fmt" - "github.com/formancehq/go-libs/v2/pointer" + "github.com/formancehq/go-libs/v3/pointer" "github.com/uptrace/bun" "reflect" "strconv" "strings" - "github.com/formancehq/go-libs/v2/time" + "github.com/formancehq/go-libs/v3/time" - "github.com/formancehq/go-libs/v2/metadata" + "github.com/formancehq/go-libs/v3/metadata" ) const ( diff --git a/internal/machine/examples/basic.go b/internal/machine/examples/basic.go index b1bf59f7ca..6b1dcd14b6 100644 --- a/internal/machine/examples/basic.go +++ b/internal/machine/examples/basic.go @@ -5,7 +5,7 @@ import ( "fmt" "math/big" - "github.com/formancehq/go-libs/v2/metadata" + "github.com/formancehq/go-libs/v3/metadata" "github.com/formancehq/ledger/internal" "github.com/formancehq/ledger/internal/machine/script/compiler" "github.com/formancehq/ledger/internal/machine/vm" diff --git a/internal/machine/funding.go b/internal/machine/funding.go index 97f633fe53..6ce0aab77d 100644 --- a/internal/machine/funding.go +++ b/internal/machine/funding.go @@ -5,7 +5,7 @@ import ( "fmt" "strings" - collec "github.com/formancehq/go-libs/v2/collectionutils" + collec "github.com/formancehq/go-libs/v3/collectionutils" ) type FundingPart struct { diff --git a/internal/machine/vm/machine.go b/internal/machine/vm/machine.go index 65f333f4b2..f0e3ab0cca 100644 --- a/internal/machine/vm/machine.go +++ b/internal/machine/vm/machine.go @@ -14,7 +14,7 @@ import ( "fmt" "math/big" - "github.com/formancehq/go-libs/v2/metadata" + "github.com/formancehq/go-libs/v3/metadata" ledger "github.com/formancehq/ledger/internal" "github.com/formancehq/ledger/internal/machine" diff --git a/internal/machine/vm/machine_test.go b/internal/machine/vm/machine_test.go index 5240cc13aa..e8a716dbcd 100644 --- a/internal/machine/vm/machine_test.go +++ b/internal/machine/vm/machine_test.go @@ -12,7 +12,7 @@ import ( "github.com/formancehq/ledger/internal/machine" "errors" - "github.com/formancehq/go-libs/v2/metadata" + "github.com/formancehq/go-libs/v3/metadata" ledger "github.com/formancehq/ledger/internal" "github.com/formancehq/ledger/internal/machine/script/compiler" "github.com/formancehq/ledger/internal/machine/vm/program" diff --git a/internal/machine/vm/run.go b/internal/machine/vm/run.go index d9fd4dad88..57f94bd151 100644 --- a/internal/machine/vm/run.go +++ b/internal/machine/vm/run.go @@ -2,12 +2,12 @@ package vm import ( "fmt" - "github.com/formancehq/go-libs/v2/time" + "github.com/formancehq/go-libs/v3/time" "math/big" "github.com/formancehq/ledger/internal/machine" - "github.com/formancehq/go-libs/v2/metadata" + "github.com/formancehq/go-libs/v3/metadata" ledger "github.com/formancehq/ledger/internal" ) diff --git a/internal/machine/vm/run_test.go b/internal/machine/vm/run_test.go index 0ef310460f..223b3604f7 100644 --- a/internal/machine/vm/run_test.go +++ b/internal/machine/vm/run_test.go @@ -8,7 +8,7 @@ import ( "github.com/formancehq/ledger/internal/machine" - "github.com/formancehq/go-libs/v2/metadata" + "github.com/formancehq/go-libs/v3/metadata" ledger "github.com/formancehq/ledger/internal" "github.com/formancehq/ledger/internal/machine/script/compiler" "github.com/stretchr/testify/require" diff --git a/internal/machine/vm/store.go b/internal/machine/vm/store.go index 2e498dfd0f..89e0b71826 100644 --- a/internal/machine/vm/store.go +++ b/internal/machine/vm/store.go @@ -4,7 +4,7 @@ import ( "context" "math/big" - "github.com/formancehq/go-libs/v2/metadata" + "github.com/formancehq/go-libs/v3/metadata" ledger "github.com/formancehq/ledger/internal" ) diff --git a/internal/moves.go b/internal/moves.go index 1c84635cae..70f4eb8dde 100644 --- a/internal/moves.go +++ b/internal/moves.go @@ -3,9 +3,9 @@ package ledger import ( "slices" - "github.com/formancehq/go-libs/v2/bun/bunpaginate" - "github.com/formancehq/go-libs/v2/collectionutils" - "github.com/formancehq/go-libs/v2/time" + "github.com/formancehq/go-libs/v3/bun/bunpaginate" + "github.com/formancehq/go-libs/v3/collectionutils" + "github.com/formancehq/go-libs/v3/time" "github.com/uptrace/bun" ) diff --git a/internal/storage/bucket/bucket.go b/internal/storage/bucket/bucket.go index 4b8802f071..96c01616ef 100644 --- a/internal/storage/bucket/bucket.go +++ b/internal/storage/bucket/bucket.go @@ -2,7 +2,7 @@ package bucket import ( "context" - "github.com/formancehq/go-libs/v2/migrations" + "github.com/formancehq/go-libs/v3/migrations" ledger "github.com/formancehq/ledger/internal" "github.com/uptrace/bun" "go.opentelemetry.io/otel/trace" diff --git a/internal/storage/bucket/default_bucket.go b/internal/storage/bucket/default_bucket.go index 7b9fd3e528..946188efcd 100644 --- a/internal/storage/bucket/default_bucket.go +++ b/internal/storage/bucket/default_bucket.go @@ -6,7 +6,7 @@ import ( _ "embed" "errors" "fmt" - "github.com/formancehq/go-libs/v2/migrations" + "github.com/formancehq/go-libs/v3/migrations" ledger "github.com/formancehq/ledger/internal" "github.com/formancehq/ledger/pkg/features" "github.com/uptrace/bun" diff --git a/internal/storage/bucket/default_bucket_test.go b/internal/storage/bucket/default_bucket_test.go index 0bb3b971d2..6cf049f2c4 100644 --- a/internal/storage/bucket/default_bucket_test.go +++ b/internal/storage/bucket/default_bucket_test.go @@ -3,15 +3,15 @@ package bucket_test import ( - "github.com/formancehq/go-libs/v2/bun/bundebug" + "github.com/formancehq/go-libs/v3/bun/bundebug" "github.com/formancehq/ledger/internal/storage/bucket" "github.com/formancehq/ledger/internal/storage/system" "go.opentelemetry.io/otel/trace/noop" "testing" - "github.com/formancehq/go-libs/v2/bun/bunconnect" + "github.com/formancehq/go-libs/v3/bun/bunconnect" - "github.com/formancehq/go-libs/v2/logging" + "github.com/formancehq/go-libs/v3/logging" "github.com/google/uuid" "github.com/stretchr/testify/require" ) diff --git a/internal/storage/bucket/main_test.go b/internal/storage/bucket/main_test.go index 6984c32c5e..978f222ff5 100644 --- a/internal/storage/bucket/main_test.go +++ b/internal/storage/bucket/main_test.go @@ -3,12 +3,12 @@ package bucket_test import ( - . "github.com/formancehq/go-libs/v2/testing/utils" + . "github.com/formancehq/go-libs/v3/testing/utils" "testing" - "github.com/formancehq/go-libs/v2/logging" - "github.com/formancehq/go-libs/v2/testing/docker" - "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" + "github.com/formancehq/go-libs/v3/logging" + "github.com/formancehq/go-libs/v3/testing/docker" + "github.com/formancehq/go-libs/v3/testing/platform/pgtesting" ) var ( diff --git a/internal/storage/bucket/migrations.go b/internal/storage/bucket/migrations.go index 7a2be00dbc..f9005f6ce4 100644 --- a/internal/storage/bucket/migrations.go +++ b/internal/storage/bucket/migrations.go @@ -6,8 +6,8 @@ import ( "embed" "errors" "fmt" - "github.com/formancehq/go-libs/v2/migrations" - "github.com/formancehq/go-libs/v2/otlp" + "github.com/formancehq/go-libs/v3/migrations" + "github.com/formancehq/go-libs/v3/otlp" "github.com/uptrace/bun" "go.opentelemetry.io/otel/trace" "gopkg.in/yaml.v3" diff --git a/internal/storage/bucket/migrations_test.go b/internal/storage/bucket/migrations_test.go index 04a644be84..be352302ea 100644 --- a/internal/storage/bucket/migrations_test.go +++ b/internal/storage/bucket/migrations_test.go @@ -5,10 +5,10 @@ package bucket_test import ( "errors" "fmt" - "github.com/formancehq/go-libs/v2/bun/bunconnect" - "github.com/formancehq/go-libs/v2/logging" - "github.com/formancehq/go-libs/v2/migrations" - "github.com/formancehq/go-libs/v2/pointer" + "github.com/formancehq/go-libs/v3/bun/bunconnect" + "github.com/formancehq/go-libs/v3/logging" + "github.com/formancehq/go-libs/v3/migrations" + "github.com/formancehq/go-libs/v3/pointer" ledger "github.com/formancehq/ledger/internal" "github.com/formancehq/ledger/internal/storage/bucket" "github.com/formancehq/ledger/internal/storage/system" diff --git a/internal/storage/common/paginator.go b/internal/storage/common/paginator.go index a797fac66f..c8896c4394 100644 --- a/internal/storage/common/paginator.go +++ b/internal/storage/common/paginator.go @@ -1,7 +1,7 @@ package common import ( - "github.com/formancehq/go-libs/v2/bun/bunpaginate" + "github.com/formancehq/go-libs/v3/bun/bunpaginate" "github.com/uptrace/bun" ) diff --git a/internal/storage/common/paginator_column.go b/internal/storage/common/paginator_column.go index dbdb5a9e04..ac0ccfe3ce 100644 --- a/internal/storage/common/paginator_column.go +++ b/internal/storage/common/paginator_column.go @@ -2,8 +2,8 @@ package common import ( "fmt" - "github.com/formancehq/go-libs/v2/bun/bunpaginate" - "github.com/formancehq/go-libs/v2/time" + "github.com/formancehq/go-libs/v3/bun/bunpaginate" + "github.com/formancehq/go-libs/v3/time" "github.com/uptrace/bun" "math/big" "reflect" diff --git a/internal/storage/common/paginator_offset.go b/internal/storage/common/paginator_offset.go index 7e2403147b..66a89db5da 100644 --- a/internal/storage/common/paginator_offset.go +++ b/internal/storage/common/paginator_offset.go @@ -2,7 +2,7 @@ package common import ( "fmt" - "github.com/formancehq/go-libs/v2/bun/bunpaginate" + "github.com/formancehq/go-libs/v3/bun/bunpaginate" "github.com/uptrace/bun" "math" ) diff --git a/internal/storage/common/resource.go b/internal/storage/common/resource.go index ba7b96158c..45ccb3b52b 100644 --- a/internal/storage/common/resource.go +++ b/internal/storage/common/resource.go @@ -4,11 +4,11 @@ import ( "context" "encoding/json" "fmt" - "github.com/formancehq/go-libs/v2/bun/bunpaginate" - "github.com/formancehq/go-libs/v2/platform/postgres" - "github.com/formancehq/go-libs/v2/pointer" - "github.com/formancehq/go-libs/v2/query" - "github.com/formancehq/go-libs/v2/time" + "github.com/formancehq/go-libs/v3/bun/bunpaginate" + "github.com/formancehq/go-libs/v3/platform/postgres" + "github.com/formancehq/go-libs/v3/pointer" + "github.com/formancehq/go-libs/v3/query" + "github.com/formancehq/go-libs/v3/time" "github.com/uptrace/bun" "math/big" "regexp" @@ -27,7 +27,8 @@ func ConvertOperatorToSQL(operator string) string { return "<=" case "$gte": return ">=" - case "$like": return "like" + case "$like": + return "like" } panic("unreachable") } diff --git a/internal/storage/driver/buckets_generated_test.go b/internal/storage/driver/buckets_generated_test.go index 506d83a9bd..9401617ccf 100644 --- a/internal/storage/driver/buckets_generated_test.go +++ b/internal/storage/driver/buckets_generated_test.go @@ -11,7 +11,7 @@ import ( context "context" reflect "reflect" - migrations "github.com/formancehq/go-libs/v2/migrations" + migrations "github.com/formancehq/go-libs/v3/migrations" ledger "github.com/formancehq/ledger/internal" bucket "github.com/formancehq/ledger/internal/storage/bucket" bun "github.com/uptrace/bun" diff --git a/internal/storage/driver/driver.go b/internal/storage/driver/driver.go index 7c6986d441..933427ff2b 100644 --- a/internal/storage/driver/driver.go +++ b/internal/storage/driver/driver.go @@ -13,10 +13,10 @@ import ( "time" "github.com/alitto/pond" - "github.com/formancehq/go-libs/v2/bun/bunpaginate" - "github.com/formancehq/go-libs/v2/logging" - "github.com/formancehq/go-libs/v2/metadata" - "github.com/formancehq/go-libs/v2/platform/postgres" + "github.com/formancehq/go-libs/v3/bun/bunpaginate" + "github.com/formancehq/go-libs/v3/logging" + "github.com/formancehq/go-libs/v3/metadata" + "github.com/formancehq/go-libs/v3/platform/postgres" ledger "github.com/formancehq/ledger/internal" systemcontroller "github.com/formancehq/ledger/internal/controller/system" "github.com/formancehq/ledger/internal/storage/bucket" diff --git a/internal/storage/driver/driver_test.go b/internal/storage/driver/driver_test.go index 8371276ccf..b3ff78bece 100644 --- a/internal/storage/driver/driver_test.go +++ b/internal/storage/driver/driver_test.go @@ -4,9 +4,9 @@ package driver_test import ( "fmt" - "github.com/formancehq/go-libs/v2/logging" - "github.com/formancehq/go-libs/v2/metadata" - "github.com/formancehq/go-libs/v2/query" + "github.com/formancehq/go-libs/v3/logging" + "github.com/formancehq/go-libs/v3/metadata" + "github.com/formancehq/go-libs/v3/query" ledger "github.com/formancehq/ledger/internal" ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" "github.com/formancehq/ledger/internal/storage/bucket" diff --git a/internal/storage/driver/main_test.go b/internal/storage/driver/main_test.go index 9d5b41bd0f..b2fb9b6261 100644 --- a/internal/storage/driver/main_test.go +++ b/internal/storage/driver/main_test.go @@ -4,19 +4,19 @@ package driver_test import ( "database/sql" - . "github.com/formancehq/go-libs/v2/testing/utils" + . "github.com/formancehq/go-libs/v3/testing/utils" systemstore "github.com/formancehq/ledger/internal/storage/system" "os" "testing" - "github.com/formancehq/go-libs/v2/bun/bundebug" - "github.com/formancehq/go-libs/v2/testing/docker" + "github.com/formancehq/go-libs/v3/bun/bundebug" + "github.com/formancehq/go-libs/v3/testing/docker" "github.com/uptrace/bun/dialect/pgdialect" "github.com/uptrace/bun" - "github.com/formancehq/go-libs/v2/logging" - "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" + "github.com/formancehq/go-libs/v3/logging" + "github.com/formancehq/go-libs/v3/testing/platform/pgtesting" "github.com/stretchr/testify/require" ) diff --git a/internal/storage/driver/module.go b/internal/storage/driver/module.go index bc27558fe3..c16c213f5c 100644 --- a/internal/storage/driver/module.go +++ b/internal/storage/driver/module.go @@ -12,7 +12,7 @@ import ( "github.com/uptrace/bun" - "github.com/formancehq/go-libs/v2/logging" + "github.com/formancehq/go-libs/v3/logging" "go.uber.org/fx" ) diff --git a/internal/storage/driver/rollbacks.go b/internal/storage/driver/rollbacks.go index 0201e58d02..22fc4288c2 100644 --- a/internal/storage/driver/rollbacks.go +++ b/internal/storage/driver/rollbacks.go @@ -4,7 +4,7 @@ import ( "context" "errors" "fmt" - "github.com/formancehq/go-libs/v2/migrations" + "github.com/formancehq/go-libs/v3/migrations" ) func detectDowngrades(migrator *migrations.Migrator, ctx context.Context) error { diff --git a/internal/storage/driver/system_generated_test.go b/internal/storage/driver/system_generated_test.go index 0a119422e9..0e24c5ebff 100644 --- a/internal/storage/driver/system_generated_test.go +++ b/internal/storage/driver/system_generated_test.go @@ -11,8 +11,8 @@ import ( context "context" reflect "reflect" - metadata "github.com/formancehq/go-libs/v2/metadata" - migrations "github.com/formancehq/go-libs/v2/migrations" + metadata "github.com/formancehq/go-libs/v3/metadata" + migrations "github.com/formancehq/go-libs/v3/migrations" ledger "github.com/formancehq/ledger/internal" common "github.com/formancehq/ledger/internal/storage/common" gomock "go.uber.org/mock/gomock" diff --git a/internal/storage/ledger/accounts.go b/internal/storage/ledger/accounts.go index 47ed625033..6c553d55ae 100644 --- a/internal/storage/ledger/accounts.go +++ b/internal/storage/ledger/accounts.go @@ -3,14 +3,14 @@ package ledger import ( "context" "fmt" - . "github.com/formancehq/go-libs/v2/collectionutils" + . "github.com/formancehq/go-libs/v3/collectionutils" "github.com/formancehq/ledger/internal/tracing" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/trace" "regexp" - "github.com/formancehq/go-libs/v2/metadata" - "github.com/formancehq/go-libs/v2/platform/postgres" + "github.com/formancehq/go-libs/v3/metadata" + "github.com/formancehq/go-libs/v3/platform/postgres" ledger "github.com/formancehq/ledger/internal" ) diff --git a/internal/storage/ledger/accounts_test.go b/internal/storage/ledger/accounts_test.go index f8d6c35211..e3c7cfc97e 100644 --- a/internal/storage/ledger/accounts_test.go +++ b/internal/storage/ledger/accounts_test.go @@ -10,13 +10,13 @@ import ( libtime "time" "errors" - "github.com/formancehq/go-libs/v2/pointer" - "github.com/formancehq/go-libs/v2/time" + "github.com/formancehq/go-libs/v3/pointer" + "github.com/formancehq/go-libs/v3/time" - "github.com/formancehq/go-libs/v2/logging" + "github.com/formancehq/go-libs/v3/logging" - "github.com/formancehq/go-libs/v2/metadata" - "github.com/formancehq/go-libs/v2/query" + "github.com/formancehq/go-libs/v3/metadata" + "github.com/formancehq/go-libs/v3/query" ledger "github.com/formancehq/ledger/internal" "github.com/stretchr/testify/require" ) diff --git a/internal/storage/ledger/balances.go b/internal/storage/ledger/balances.go index b7ae9ad69b..6c3f4fd2c2 100644 --- a/internal/storage/ledger/balances.go +++ b/internal/storage/ledger/balances.go @@ -6,7 +6,7 @@ import ( "slices" "strings" - "github.com/formancehq/go-libs/v2/platform/postgres" + "github.com/formancehq/go-libs/v3/platform/postgres" "github.com/formancehq/ledger/internal/tracing" diff --git a/internal/storage/ledger/balances_test.go b/internal/storage/ledger/balances_test.go index ae445d681a..c56936b01f 100644 --- a/internal/storage/ledger/balances_test.go +++ b/internal/storage/ledger/balances_test.go @@ -8,16 +8,16 @@ import ( "math/big" "testing" - "github.com/formancehq/go-libs/v2/metadata" - "github.com/formancehq/go-libs/v2/time" + "github.com/formancehq/go-libs/v3/metadata" + "github.com/formancehq/go-libs/v3/time" ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" - "github.com/formancehq/go-libs/v2/logging" - "github.com/formancehq/go-libs/v2/pointer" + "github.com/formancehq/go-libs/v3/logging" + "github.com/formancehq/go-libs/v3/pointer" libtime "time" - "github.com/formancehq/go-libs/v2/query" + "github.com/formancehq/go-libs/v3/query" ledger "github.com/formancehq/ledger/internal" "github.com/stretchr/testify/require" ) diff --git a/internal/storage/ledger/logs.go b/internal/storage/ledger/logs.go index 38fd2670c6..0a88c4cc24 100644 --- a/internal/storage/ledger/logs.go +++ b/internal/storage/ledger/logs.go @@ -9,8 +9,8 @@ import ( "github.com/formancehq/ledger/pkg/features" "errors" - "github.com/formancehq/go-libs/v2/platform/postgres" - "github.com/formancehq/go-libs/v2/pointer" + "github.com/formancehq/go-libs/v3/platform/postgres" + "github.com/formancehq/go-libs/v3/pointer" ledger "github.com/formancehq/ledger/internal" ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" ) diff --git a/internal/storage/ledger/logs_test.go b/internal/storage/ledger/logs_test.go index dfeff4d442..de813a5966 100644 --- a/internal/storage/ledger/logs_test.go +++ b/internal/storage/ledger/logs_test.go @@ -5,8 +5,8 @@ package ledger_test import ( "context" "database/sql" - "github.com/formancehq/go-libs/v2/metadata" - "github.com/formancehq/go-libs/v2/pointer" + "github.com/formancehq/go-libs/v3/metadata" + "github.com/formancehq/go-libs/v3/pointer" "github.com/formancehq/ledger/internal/storage/common" "golang.org/x/sync/errgroup" "math/big" @@ -15,12 +15,12 @@ import ( "errors" ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" - "github.com/formancehq/go-libs/v2/bun/bunpaginate" - "github.com/formancehq/go-libs/v2/time" + "github.com/formancehq/go-libs/v3/bun/bunpaginate" + "github.com/formancehq/go-libs/v3/time" - "github.com/formancehq/go-libs/v2/logging" + "github.com/formancehq/go-libs/v3/logging" - "github.com/formancehq/go-libs/v2/query" + "github.com/formancehq/go-libs/v3/query" ledger "github.com/formancehq/ledger/internal" "github.com/stretchr/testify/require" ) diff --git a/internal/storage/ledger/main_test.go b/internal/storage/ledger/main_test.go index b787f52608..ebb5051e65 100644 --- a/internal/storage/ledger/main_test.go +++ b/internal/storage/ledger/main_test.go @@ -4,9 +4,9 @@ package ledger_test import ( "database/sql" - "github.com/formancehq/go-libs/v2/bun/bundebug" - "github.com/formancehq/go-libs/v2/testing/deferred" - . "github.com/formancehq/go-libs/v2/testing/utils" + "github.com/formancehq/go-libs/v3/bun/bundebug" + "github.com/formancehq/go-libs/v3/testing/deferred" + . "github.com/formancehq/go-libs/v3/testing/utils" "github.com/formancehq/ledger/internal/storage/bucket" "github.com/formancehq/ledger/internal/storage/driver" ledgerstore "github.com/formancehq/ledger/internal/storage/ledger" @@ -15,7 +15,7 @@ import ( "os" "testing" - "github.com/formancehq/go-libs/v2/testing/docker" + "github.com/formancehq/go-libs/v3/testing/docker" ledger "github.com/formancehq/ledger/internal" "github.com/google/go-cmp/cmp" @@ -23,8 +23,8 @@ import ( "github.com/uptrace/bun" - "github.com/formancehq/go-libs/v2/logging" - "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" + "github.com/formancehq/go-libs/v3/logging" + "github.com/formancehq/go-libs/v3/testing/platform/pgtesting" "github.com/google/uuid" "github.com/stretchr/testify/require" ) diff --git a/internal/storage/ledger/moves.go b/internal/storage/ledger/moves.go index 00dbc86cc4..d63a3aacb2 100644 --- a/internal/storage/ledger/moves.go +++ b/internal/storage/ledger/moves.go @@ -2,7 +2,7 @@ package ledger import ( "context" - "github.com/formancehq/go-libs/v2/platform/postgres" + "github.com/formancehq/go-libs/v3/platform/postgres" ledger "github.com/formancehq/ledger/internal" "github.com/formancehq/ledger/internal/tracing" ) diff --git a/internal/storage/ledger/moves_test.go b/internal/storage/ledger/moves_test.go index 6dc4d16eba..63cfc647f8 100644 --- a/internal/storage/ledger/moves_test.go +++ b/internal/storage/ledger/moves_test.go @@ -12,10 +12,10 @@ import ( "errors" "github.com/alitto/pond" - "github.com/formancehq/go-libs/v2/bun/bunpaginate" - "github.com/formancehq/go-libs/v2/logging" - "github.com/formancehq/go-libs/v2/platform/postgres" - "github.com/formancehq/go-libs/v2/time" + "github.com/formancehq/go-libs/v3/bun/bunpaginate" + "github.com/formancehq/go-libs/v3/logging" + "github.com/formancehq/go-libs/v3/platform/postgres" + "github.com/formancehq/go-libs/v3/time" ledger "github.com/formancehq/ledger/internal" ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" "github.com/stretchr/testify/require" diff --git a/internal/storage/ledger/store.go b/internal/storage/ledger/store.go index 760a745c54..e964b89aba 100644 --- a/internal/storage/ledger/store.go +++ b/internal/storage/ledger/store.go @@ -4,9 +4,9 @@ import ( "context" "database/sql" "fmt" - "github.com/formancehq/go-libs/v2/bun/bunpaginate" - "github.com/formancehq/go-libs/v2/migrations" - "github.com/formancehq/go-libs/v2/platform/postgres" + "github.com/formancehq/go-libs/v3/bun/bunpaginate" + "github.com/formancehq/go-libs/v3/migrations" + "github.com/formancehq/go-libs/v3/platform/postgres" ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" "github.com/formancehq/ledger/internal/storage/bucket" "github.com/formancehq/ledger/internal/storage/common" diff --git a/internal/storage/ledger/transactions.go b/internal/storage/ledger/transactions.go index 8ef83701d1..86864906d1 100644 --- a/internal/storage/ledger/transactions.go +++ b/internal/storage/ledger/transactions.go @@ -4,7 +4,7 @@ import ( "context" "encoding/json" "fmt" - . "github.com/formancehq/go-libs/v2/collectionutils" + . "github.com/formancehq/go-libs/v3/collectionutils" "github.com/formancehq/ledger/pkg/features" "math/big" "slices" @@ -13,18 +13,18 @@ import ( "github.com/formancehq/ledger/internal/tracing" "errors" - "github.com/formancehq/go-libs/v2/platform/postgres" + "github.com/formancehq/go-libs/v3/platform/postgres" ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/trace" - "github.com/formancehq/go-libs/v2/pointer" + "github.com/formancehq/go-libs/v3/pointer" - "github.com/formancehq/go-libs/v2/time" + "github.com/formancehq/go-libs/v3/time" - "github.com/formancehq/go-libs/v2/bun/bunpaginate" + "github.com/formancehq/go-libs/v3/bun/bunpaginate" - "github.com/formancehq/go-libs/v2/metadata" + "github.com/formancehq/go-libs/v3/metadata" ledger "github.com/formancehq/ledger/internal" "github.com/uptrace/bun" ) diff --git a/internal/storage/ledger/transactions_test.go b/internal/storage/ledger/transactions_test.go index fd004207b0..6db4d65b84 100644 --- a/internal/storage/ledger/transactions_test.go +++ b/internal/storage/ledger/transactions_test.go @@ -12,19 +12,19 @@ import ( "slices" "testing" - "github.com/formancehq/go-libs/v2/platform/postgres" - "github.com/formancehq/go-libs/v2/time" + "github.com/formancehq/go-libs/v3/platform/postgres" + "github.com/formancehq/go-libs/v3/time" ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" "errors" - "github.com/formancehq/go-libs/v2/logging" - "github.com/formancehq/go-libs/v2/pointer" + "github.com/formancehq/go-libs/v3/logging" + "github.com/formancehq/go-libs/v3/pointer" libtime "time" - "github.com/formancehq/go-libs/v2/metadata" - "github.com/formancehq/go-libs/v2/query" + "github.com/formancehq/go-libs/v3/metadata" + "github.com/formancehq/go-libs/v3/query" ledger "github.com/formancehq/ledger/internal" "github.com/stretchr/testify/require" ) diff --git a/internal/storage/ledger/volumes.go b/internal/storage/ledger/volumes.go index f11932c33e..0801abf7f8 100644 --- a/internal/storage/ledger/volumes.go +++ b/internal/storage/ledger/volumes.go @@ -2,8 +2,8 @@ package ledger import ( "context" - "github.com/formancehq/go-libs/v2/collectionutils" - "github.com/formancehq/go-libs/v2/platform/postgres" + "github.com/formancehq/go-libs/v3/collectionutils" + "github.com/formancehq/go-libs/v3/platform/postgres" ledger "github.com/formancehq/ledger/internal" "github.com/formancehq/ledger/internal/tracing" ) diff --git a/internal/storage/ledger/volumes_test.go b/internal/storage/ledger/volumes_test.go index 4f246b9ade..4296282665 100644 --- a/internal/storage/ledger/volumes_test.go +++ b/internal/storage/ledger/volumes_test.go @@ -4,22 +4,22 @@ package ledger_test import ( "database/sql" - "github.com/formancehq/go-libs/v2/pointer" + "github.com/formancehq/go-libs/v3/pointer" "github.com/formancehq/ledger/internal/storage/common" "math/big" "testing" libtime "time" "errors" - "github.com/formancehq/go-libs/v2/platform/postgres" + "github.com/formancehq/go-libs/v3/platform/postgres" ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" - "github.com/formancehq/go-libs/v2/time" + "github.com/formancehq/go-libs/v3/time" - "github.com/formancehq/go-libs/v2/logging" + "github.com/formancehq/go-libs/v3/logging" - "github.com/formancehq/go-libs/v2/metadata" - "github.com/formancehq/go-libs/v2/query" + "github.com/formancehq/go-libs/v3/metadata" + "github.com/formancehq/go-libs/v3/query" ledger "github.com/formancehq/ledger/internal" "github.com/stretchr/testify/require" ) diff --git a/internal/storage/module.go b/internal/storage/module.go index 2490d2eacb..9750e8a968 100644 --- a/internal/storage/module.go +++ b/internal/storage/module.go @@ -3,8 +3,8 @@ package storage import ( "context" "errors" - "github.com/formancehq/go-libs/v2/health" - "github.com/formancehq/go-libs/v2/logging" + "github.com/formancehq/go-libs/v3/health" + "github.com/formancehq/go-libs/v3/logging" "github.com/formancehq/ledger/internal/storage/driver" "github.com/formancehq/ledger/internal/tracing" "go.opentelemetry.io/otel/trace" diff --git a/internal/storage/system/main_test.go b/internal/storage/system/main_test.go index 0e27d35f94..3fe92de3b0 100644 --- a/internal/storage/system/main_test.go +++ b/internal/storage/system/main_test.go @@ -5,11 +5,11 @@ package system import ( "testing" - "github.com/formancehq/go-libs/v2/testing/docker" - "github.com/formancehq/go-libs/v2/testing/utils" + "github.com/formancehq/go-libs/v3/testing/docker" + "github.com/formancehq/go-libs/v3/testing/utils" - "github.com/formancehq/go-libs/v2/logging" - "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" + "github.com/formancehq/go-libs/v3/logging" + "github.com/formancehq/go-libs/v3/testing/platform/pgtesting" ) var srv *pgtesting.PostgresServer diff --git a/internal/storage/system/migrations.go b/internal/storage/system/migrations.go index 0bdbbb4d8f..045894d1d1 100644 --- a/internal/storage/system/migrations.go +++ b/internal/storage/system/migrations.go @@ -3,11 +3,11 @@ package system import ( "context" "database/sql" - "github.com/formancehq/go-libs/v2/platform/postgres" - "github.com/formancehq/go-libs/v2/time" + "github.com/formancehq/go-libs/v3/platform/postgres" + "github.com/formancehq/go-libs/v3/time" "github.com/formancehq/ledger/pkg/features" - "github.com/formancehq/go-libs/v2/migrations" + "github.com/formancehq/go-libs/v3/migrations" "github.com/uptrace/bun" ) diff --git a/internal/storage/system/migrations_test.go b/internal/storage/system/migrations_test.go index 0b25b7bbb4..2b4dc9e754 100644 --- a/internal/storage/system/migrations_test.go +++ b/internal/storage/system/migrations_test.go @@ -5,15 +5,15 @@ package system import ( "context" "fmt" - "github.com/formancehq/go-libs/v2/testing/migrations" + "github.com/formancehq/go-libs/v3/testing/migrations" "github.com/formancehq/ledger/pkg/features" "os" "testing" - "github.com/formancehq/go-libs/v2/bun/bunconnect" - "github.com/formancehq/go-libs/v2/bun/bundebug" - "github.com/formancehq/go-libs/v2/logging" - "github.com/formancehq/go-libs/v2/time" + "github.com/formancehq/go-libs/v3/bun/bunconnect" + "github.com/formancehq/go-libs/v3/bun/bundebug" + "github.com/formancehq/go-libs/v3/logging" + "github.com/formancehq/go-libs/v3/time" ledger "github.com/formancehq/ledger/internal" "github.com/stretchr/testify/require" "github.com/uptrace/bun" diff --git a/internal/storage/system/store.go b/internal/storage/system/store.go index 442b6f9feb..b293fb7f08 100644 --- a/internal/storage/system/store.go +++ b/internal/storage/system/store.go @@ -4,10 +4,10 @@ import ( "context" "errors" "fmt" - "github.com/formancehq/go-libs/v2/bun/bunpaginate" - "github.com/formancehq/go-libs/v2/metadata" - "github.com/formancehq/go-libs/v2/migrations" - "github.com/formancehq/go-libs/v2/platform/postgres" + "github.com/formancehq/go-libs/v3/bun/bunpaginate" + "github.com/formancehq/go-libs/v3/metadata" + "github.com/formancehq/go-libs/v3/migrations" + "github.com/formancehq/go-libs/v3/platform/postgres" ledger "github.com/formancehq/ledger/internal" systemcontroller "github.com/formancehq/ledger/internal/controller/system" "github.com/formancehq/ledger/internal/storage/common" diff --git a/internal/storage/system/store_test.go b/internal/storage/system/store_test.go index 61b6708b09..c3778abae0 100644 --- a/internal/storage/system/store_test.go +++ b/internal/storage/system/store_test.go @@ -5,11 +5,11 @@ package system import ( "context" "fmt" - "github.com/formancehq/go-libs/v2/bun/bunconnect" - "github.com/formancehq/go-libs/v2/bun/bundebug" - "github.com/formancehq/go-libs/v2/bun/bunpaginate" - "github.com/formancehq/go-libs/v2/metadata" - "github.com/formancehq/go-libs/v2/testing/docker" + "github.com/formancehq/go-libs/v3/bun/bunconnect" + "github.com/formancehq/go-libs/v3/bun/bundebug" + "github.com/formancehq/go-libs/v3/bun/bunpaginate" + "github.com/formancehq/go-libs/v3/metadata" + "github.com/formancehq/go-libs/v3/testing/docker" ledger "github.com/formancehq/ledger/internal" ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" "github.com/formancehq/ledger/internal/storage/common" @@ -21,7 +21,7 @@ import ( "testing" "time" - "github.com/formancehq/go-libs/v2/logging" + "github.com/formancehq/go-libs/v3/logging" "github.com/stretchr/testify/require" ) diff --git a/internal/tracing/tracing.go b/internal/tracing/tracing.go index 0f4f9f5197..1d77ccbe1d 100644 --- a/internal/tracing/tracing.go +++ b/internal/tracing/tracing.go @@ -2,8 +2,8 @@ package tracing import ( "context" - "github.com/formancehq/go-libs/v2/otlp" - "github.com/formancehq/go-libs/v2/time" + "github.com/formancehq/go-libs/v3/otlp" + "github.com/formancehq/go-libs/v3/time" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/metric" diff --git a/internal/transaction.go b/internal/transaction.go index 54df9d758e..f5d6a6bacf 100644 --- a/internal/transaction.go +++ b/internal/transaction.go @@ -2,14 +2,14 @@ package ledger import ( "encoding/json" - "github.com/formancehq/go-libs/v2/time" + "github.com/formancehq/go-libs/v3/time" "github.com/invopop/jsonschema" "github.com/uptrace/bun" "math/big" "slices" "sort" - "github.com/formancehq/go-libs/v2/metadata" + "github.com/formancehq/go-libs/v3/metadata" ) type Transactions struct { @@ -39,7 +39,7 @@ type Transaction struct { bun.BaseModel `bun:"table:transactions,alias:transactions"` TransactionData - ID *int `json:"id" bun:"id,type:numeric"` + ID *int `json:"id" bun:"id,type:numeric"` RevertedAt *time.Time `json:"revertedAt,omitempty" bun:"reverted_at,type:timestamp without time zone"` // PostCommitVolumes are the volumes of each account/asset after a transaction has been committed. // Those volumes will never change as those are computed in flight. diff --git a/internal/transaction_test.go b/internal/transaction_test.go index 391583ff61..eb3c0a7a08 100644 --- a/internal/transaction_test.go +++ b/internal/transaction_test.go @@ -2,12 +2,12 @@ package ledger import ( "encoding/base64" - "github.com/formancehq/go-libs/v2/metadata" - "github.com/formancehq/go-libs/v2/pointer" + "github.com/formancehq/go-libs/v3/metadata" + "github.com/formancehq/go-libs/v3/pointer" "math/big" "testing" - "github.com/formancehq/go-libs/v2/time" + "github.com/formancehq/go-libs/v3/time" "github.com/stretchr/testify/require" ) diff --git a/internal/worker/async_block.go b/internal/worker/async_block.go index 3b655d5d48..450c17c84d 100644 --- a/internal/worker/async_block.go +++ b/internal/worker/async_block.go @@ -3,9 +3,9 @@ package worker import ( "context" "fmt" - "github.com/formancehq/go-libs/v2/bun/bunpaginate" - "github.com/formancehq/go-libs/v2/logging" - "github.com/formancehq/go-libs/v2/query" + "github.com/formancehq/go-libs/v3/bun/bunpaginate" + "github.com/formancehq/go-libs/v3/logging" + "github.com/formancehq/go-libs/v3/query" "github.com/formancehq/ledger/internal" ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" "github.com/formancehq/ledger/internal/storage/common" @@ -136,4 +136,4 @@ func WithTracer(tracer trace.Tracer) Option { var defaultOptions = []Option{ WithTracer(noop.Tracer{}), -} \ No newline at end of file +} diff --git a/internal/worker/fx.go b/internal/worker/fx.go index 06972da63c..6e6e772a3c 100644 --- a/internal/worker/fx.go +++ b/internal/worker/fx.go @@ -2,7 +2,7 @@ package worker import ( "context" - "github.com/formancehq/go-libs/v2/logging" + "github.com/formancehq/go-libs/v3/logging" "github.com/robfig/cron/v3" "github.com/uptrace/bun" "go.opentelemetry.io/otel/trace" diff --git a/pkg/features/features.go b/pkg/features/features.go index 0f824cdbbc..e2b895b32d 100644 --- a/pkg/features/features.go +++ b/pkg/features/features.go @@ -2,7 +2,7 @@ package features import ( "fmt" - "github.com/formancehq/go-libs/v2/collectionutils" + "github.com/formancehq/go-libs/v3/collectionutils" "slices" "strings" ) diff --git a/pkg/generate/generator.go b/pkg/generate/generator.go index 15a52be635..dde914db13 100644 --- a/pkg/generate/generator.go +++ b/pkg/generate/generator.go @@ -6,8 +6,8 @@ import ( "errors" "fmt" "github.com/dop251/goja" - "github.com/formancehq/go-libs/v2/collectionutils" - "github.com/formancehq/go-libs/v2/pointer" + "github.com/formancehq/go-libs/v3/collectionutils" + "github.com/formancehq/go-libs/v3/pointer" ledger "github.com/formancehq/ledger/internal" "github.com/formancehq/ledger/internal/api/bulking" "github.com/formancehq/ledger/pkg/client" diff --git a/pkg/generate/generator_test.go b/pkg/generate/generator_test.go index 8f27f35924..6e2b3644d4 100644 --- a/pkg/generate/generator_test.go +++ b/pkg/generate/generator_test.go @@ -3,12 +3,12 @@ package generate import ( - "github.com/formancehq/go-libs/v2/bun/bunconnect" - "github.com/formancehq/go-libs/v2/logging" - "github.com/formancehq/go-libs/v2/testing/deferred" - "github.com/formancehq/go-libs/v2/testing/docker" - "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" - "github.com/formancehq/go-libs/v2/testing/testservice" + "github.com/formancehq/go-libs/v3/bun/bunconnect" + "github.com/formancehq/go-libs/v3/logging" + "github.com/formancehq/go-libs/v3/testing/deferred" + "github.com/formancehq/go-libs/v3/testing/docker" + "github.com/formancehq/go-libs/v3/testing/platform/pgtesting" + "github.com/formancehq/go-libs/v3/testing/testservice" "github.com/formancehq/ledger/pkg/client/models/operations" . "github.com/formancehq/ledger/pkg/testserver" "github.com/stretchr/testify/require" diff --git a/pkg/generate/set.go b/pkg/generate/set.go index 610e8542e5..619fb45d82 100644 --- a/pkg/generate/set.go +++ b/pkg/generate/set.go @@ -4,9 +4,9 @@ import ( "context" "errors" "fmt" - "github.com/formancehq/go-libs/v2/collectionutils" - "github.com/formancehq/go-libs/v2/logging" - "github.com/formancehq/go-libs/v2/pointer" + "github.com/formancehq/go-libs/v3/collectionutils" + "github.com/formancehq/go-libs/v3/logging" + "github.com/formancehq/go-libs/v3/pointer" "github.com/formancehq/ledger/pkg/client" "github.com/formancehq/ledger/pkg/client/models/components" "github.com/formancehq/ledger/pkg/client/models/operations" diff --git a/pkg/testserver/client.go b/pkg/testserver/client.go index c33ab7e025..42e8a70ad3 100644 --- a/pkg/testserver/client.go +++ b/pkg/testserver/client.go @@ -1,8 +1,8 @@ package testserver import ( - "github.com/formancehq/go-libs/v2/testing/deferred" - "github.com/formancehq/go-libs/v2/testing/testservice" + "github.com/formancehq/go-libs/v3/testing/deferred" + "github.com/formancehq/go-libs/v3/testing/testservice" ledgerclient "github.com/formancehq/ledger/pkg/client" ) diff --git a/pkg/testserver/ginkgo/helpers.go b/pkg/testserver/ginkgo/helpers.go index 972f3de202..9a0453f05a 100644 --- a/pkg/testserver/ginkgo/helpers.go +++ b/pkg/testserver/ginkgo/helpers.go @@ -1,10 +1,10 @@ package ginkgo import ( - "github.com/formancehq/go-libs/v2/bun/bunconnect" - "github.com/formancehq/go-libs/v2/testing/deferred" - "github.com/formancehq/go-libs/v2/testing/testservice" - . "github.com/formancehq/go-libs/v2/testing/testservice/ginkgo" + "github.com/formancehq/go-libs/v3/bun/bunconnect" + "github.com/formancehq/go-libs/v3/testing/deferred" + "github.com/formancehq/go-libs/v3/testing/testservice" + . "github.com/formancehq/go-libs/v3/testing/testservice/ginkgo" "github.com/formancehq/ledger/cmd" "github.com/formancehq/ledger/pkg/testserver" ) diff --git a/pkg/testserver/ginkgo/matchers.go b/pkg/testserver/ginkgo/matchers.go index e4ebef05d0..ca2bbd9674 100644 --- a/pkg/testserver/ginkgo/matchers.go +++ b/pkg/testserver/ginkgo/matchers.go @@ -5,10 +5,10 @@ import ( "encoding/json" "errors" "fmt" - "github.com/formancehq/go-libs/v2/pointer" - "github.com/formancehq/go-libs/v2/publish" - "github.com/formancehq/go-libs/v2/testing/deferred" - "github.com/formancehq/go-libs/v2/testing/testservice" + "github.com/formancehq/go-libs/v3/pointer" + "github.com/formancehq/go-libs/v3/publish" + "github.com/formancehq/go-libs/v3/testing/deferred" + "github.com/formancehq/go-libs/v3/testing/testservice" "github.com/formancehq/ledger/pkg/client/models/operations" "github.com/formancehq/ledger/pkg/testserver" "github.com/google/go-cmp/cmp" diff --git a/pkg/testserver/server.go b/pkg/testserver/server.go index eaadefbb8f..b46b1d1d3b 100644 --- a/pkg/testserver/server.go +++ b/pkg/testserver/server.go @@ -3,9 +3,9 @@ package testserver import ( "context" "fmt" - "github.com/formancehq/go-libs/v2/bun/bunconnect" - "github.com/formancehq/go-libs/v2/testing/deferred" - "github.com/formancehq/go-libs/v2/testing/testservice" + "github.com/formancehq/go-libs/v3/bun/bunconnect" + "github.com/formancehq/go-libs/v3/testing/deferred" + "github.com/formancehq/go-libs/v3/testing/testservice" "github.com/formancehq/ledger/cmd" ) diff --git a/pkg/testserver/utils.go b/pkg/testserver/utils.go index b95be84db3..7ed3ff4a34 100644 --- a/pkg/testserver/utils.go +++ b/pkg/testserver/utils.go @@ -1,9 +1,9 @@ package testserver import ( - "github.com/formancehq/go-libs/v2/collectionutils" - "github.com/formancehq/go-libs/v2/pointer" - "github.com/formancehq/go-libs/v2/time" + "github.com/formancehq/go-libs/v3/collectionutils" + "github.com/formancehq/go-libs/v3/pointer" + "github.com/formancehq/go-libs/v3/time" ledger "github.com/formancehq/ledger/internal" "github.com/formancehq/ledger/pkg/client/models/components" ) diff --git a/pkg/testserver/worker.go b/pkg/testserver/worker.go index 670118c2a3..989fc9a7c8 100644 --- a/pkg/testserver/worker.go +++ b/pkg/testserver/worker.go @@ -2,7 +2,7 @@ package testserver import ( "context" - "github.com/formancehq/go-libs/v2/testing/testservice" + "github.com/formancehq/go-libs/v3/testing/testservice" "github.com/formancehq/ledger/cmd" "strconv" ) diff --git a/test/e2e/api_accounts_list_test.go b/test/e2e/api_accounts_list_test.go index 7baeffdf84..ff99003b7e 100644 --- a/test/e2e/api_accounts_list_test.go +++ b/test/e2e/api_accounts_list_test.go @@ -4,12 +4,12 @@ package test_suite import ( "fmt" - "github.com/formancehq/go-libs/v2/logging" - . "github.com/formancehq/go-libs/v2/testing/api" - . "github.com/formancehq/go-libs/v2/testing/deferred/ginkgo" - "github.com/formancehq/go-libs/v2/testing/platform/natstesting" - "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" - "github.com/formancehq/go-libs/v2/testing/testservice" + "github.com/formancehq/go-libs/v3/logging" + . "github.com/formancehq/go-libs/v3/testing/api" + . "github.com/formancehq/go-libs/v3/testing/deferred/ginkgo" + "github.com/formancehq/go-libs/v3/testing/platform/natstesting" + "github.com/formancehq/go-libs/v3/testing/platform/pgtesting" + "github.com/formancehq/go-libs/v3/testing/testservice" "github.com/formancehq/ledger/pkg/client/models/components" "github.com/formancehq/ledger/pkg/client/models/operations" . "github.com/formancehq/ledger/pkg/testserver" @@ -18,9 +18,9 @@ import ( "sort" "time" - "github.com/formancehq/go-libs/v2/pointer" + "github.com/formancehq/go-libs/v3/pointer" - "github.com/formancehq/go-libs/v2/metadata" + "github.com/formancehq/go-libs/v3/metadata" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/test/e2e/api_accounts_metadata_test.go b/test/e2e/api_accounts_metadata_test.go index 90e3afc8e0..9a2b36d667 100644 --- a/test/e2e/api_accounts_metadata_test.go +++ b/test/e2e/api_accounts_metadata_test.go @@ -3,12 +3,12 @@ package test_suite import ( - "github.com/formancehq/go-libs/v2/logging" - "github.com/formancehq/go-libs/v2/testing/deferred/ginkgo" - . "github.com/formancehq/go-libs/v2/testing/deferred/ginkgo" - "github.com/formancehq/go-libs/v2/testing/platform/natstesting" - "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" - "github.com/formancehq/go-libs/v2/testing/testservice" + "github.com/formancehq/go-libs/v3/logging" + "github.com/formancehq/go-libs/v3/testing/deferred/ginkgo" + . "github.com/formancehq/go-libs/v3/testing/deferred/ginkgo" + "github.com/formancehq/go-libs/v3/testing/platform/natstesting" + "github.com/formancehq/go-libs/v3/testing/platform/pgtesting" + "github.com/formancehq/go-libs/v3/testing/testservice" "github.com/formancehq/ledger/pkg/client/models/components" "github.com/formancehq/ledger/pkg/client/models/operations" ledgerevents "github.com/formancehq/ledger/pkg/events" diff --git a/test/e2e/api_balances_aggregated_test.go b/test/e2e/api_balances_aggregated_test.go index 23a4de019c..77099ef7d0 100644 --- a/test/e2e/api_balances_aggregated_test.go +++ b/test/e2e/api_balances_aggregated_test.go @@ -3,11 +3,11 @@ package test_suite import ( - "github.com/formancehq/go-libs/v2/logging" - "github.com/formancehq/go-libs/v2/pointer" - . "github.com/formancehq/go-libs/v2/testing/deferred/ginkgo" - "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" - "github.com/formancehq/go-libs/v2/testing/testservice" + "github.com/formancehq/go-libs/v3/logging" + "github.com/formancehq/go-libs/v3/pointer" + . "github.com/formancehq/go-libs/v3/testing/deferred/ginkgo" + "github.com/formancehq/go-libs/v3/testing/platform/pgtesting" + "github.com/formancehq/go-libs/v3/testing/testservice" "github.com/formancehq/ledger/pkg/client/models/components" "github.com/formancehq/ledger/pkg/client/models/operations" . "github.com/formancehq/ledger/pkg/testserver" diff --git a/test/e2e/api_bulk_test.go b/test/e2e/api_bulk_test.go index 563686e590..44410240db 100644 --- a/test/e2e/api_bulk_test.go +++ b/test/e2e/api_bulk_test.go @@ -5,12 +5,12 @@ package test_suite import ( "bytes" "encoding/json" - "github.com/formancehq/go-libs/v2/pointer" - "github.com/formancehq/go-libs/v2/testing/deferred/ginkgo" - . "github.com/formancehq/go-libs/v2/testing/deferred/ginkgo" - "github.com/formancehq/go-libs/v2/testing/platform/natstesting" - "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" - "github.com/formancehq/go-libs/v2/testing/testservice" + "github.com/formancehq/go-libs/v3/pointer" + "github.com/formancehq/go-libs/v3/testing/deferred/ginkgo" + . "github.com/formancehq/go-libs/v3/testing/deferred/ginkgo" + "github.com/formancehq/go-libs/v3/testing/platform/natstesting" + "github.com/formancehq/go-libs/v3/testing/platform/pgtesting" + "github.com/formancehq/go-libs/v3/testing/testservice" ledger "github.com/formancehq/ledger/internal" "github.com/formancehq/ledger/internal/bus" ledgerevents "github.com/formancehq/ledger/pkg/events" @@ -20,13 +20,13 @@ import ( "net/http" "time" - "github.com/formancehq/go-libs/v2/logging" - . "github.com/formancehq/go-libs/v2/testing/api" + "github.com/formancehq/go-libs/v3/logging" + . "github.com/formancehq/go-libs/v3/testing/api" "github.com/formancehq/ledger/pkg/client/models/components" "github.com/formancehq/ledger/pkg/client/models/operations" . "github.com/formancehq/ledger/pkg/testserver" - "github.com/formancehq/go-libs/v2/metadata" + "github.com/formancehq/go-libs/v3/metadata" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/test/e2e/api_ledgers_create_test.go b/test/e2e/api_ledgers_create_test.go index 0736f8b08d..980f11803f 100644 --- a/test/e2e/api_ledgers_create_test.go +++ b/test/e2e/api_ledgers_create_test.go @@ -3,13 +3,13 @@ package test_suite import ( - "github.com/formancehq/go-libs/v2/logging" - "github.com/formancehq/go-libs/v2/pointer" - . "github.com/formancehq/go-libs/v2/testing/api" - . "github.com/formancehq/go-libs/v2/testing/deferred/ginkgo" - "github.com/formancehq/go-libs/v2/testing/platform/natstesting" - "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" - "github.com/formancehq/go-libs/v2/testing/testservice" + "github.com/formancehq/go-libs/v3/logging" + "github.com/formancehq/go-libs/v3/pointer" + . "github.com/formancehq/go-libs/v3/testing/api" + . "github.com/formancehq/go-libs/v3/testing/deferred/ginkgo" + "github.com/formancehq/go-libs/v3/testing/platform/natstesting" + "github.com/formancehq/go-libs/v3/testing/platform/pgtesting" + "github.com/formancehq/go-libs/v3/testing/testservice" "github.com/formancehq/ledger/pkg/client/models/components" "github.com/formancehq/ledger/pkg/client/models/operations" "github.com/formancehq/ledger/pkg/features" diff --git a/test/e2e/api_ledgers_import_test.go b/test/e2e/api_ledgers_import_test.go index b019082cab..b0b7046ebf 100644 --- a/test/e2e/api_ledgers_import_test.go +++ b/test/e2e/api_ledgers_import_test.go @@ -4,12 +4,12 @@ package test_suite import ( "database/sql" - "github.com/formancehq/go-libs/v2/logging" - "github.com/formancehq/go-libs/v2/pointer" - . "github.com/formancehq/go-libs/v2/testing/api" - . "github.com/formancehq/go-libs/v2/testing/deferred/ginkgo" - "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" - "github.com/formancehq/go-libs/v2/testing/testservice" + "github.com/formancehq/go-libs/v3/logging" + "github.com/formancehq/go-libs/v3/pointer" + . "github.com/formancehq/go-libs/v3/testing/api" + . "github.com/formancehq/go-libs/v3/testing/deferred/ginkgo" + "github.com/formancehq/go-libs/v3/testing/platform/pgtesting" + "github.com/formancehq/go-libs/v3/testing/testservice" "github.com/formancehq/ledger/pkg/client/models/components" "github.com/formancehq/ledger/pkg/client/models/operations" "github.com/formancehq/ledger/pkg/features" diff --git a/test/e2e/api_ledgers_list_test.go b/test/e2e/api_ledgers_list_test.go index f66c402e04..d0de8fd5ee 100644 --- a/test/e2e/api_ledgers_list_test.go +++ b/test/e2e/api_ledgers_list_test.go @@ -4,11 +4,11 @@ package test_suite import ( "fmt" - "github.com/formancehq/go-libs/v2/logging" - "github.com/formancehq/go-libs/v2/pointer" - . "github.com/formancehq/go-libs/v2/testing/deferred/ginkgo" - "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" - "github.com/formancehq/go-libs/v2/testing/testservice" + "github.com/formancehq/go-libs/v3/logging" + "github.com/formancehq/go-libs/v3/pointer" + . "github.com/formancehq/go-libs/v3/testing/deferred/ginkgo" + "github.com/formancehq/go-libs/v3/testing/platform/pgtesting" + "github.com/formancehq/go-libs/v3/testing/testservice" "github.com/formancehq/ledger/pkg/client/models/components" "github.com/formancehq/ledger/pkg/client/models/operations" . "github.com/formancehq/ledger/pkg/testserver" diff --git a/test/e2e/api_ledgers_metadata_test.go b/test/e2e/api_ledgers_metadata_test.go index fb6a4a7cb3..5a5b6e9f8d 100644 --- a/test/e2e/api_ledgers_metadata_test.go +++ b/test/e2e/api_ledgers_metadata_test.go @@ -3,10 +3,10 @@ package test_suite import ( - "github.com/formancehq/go-libs/v2/logging" - . "github.com/formancehq/go-libs/v2/testing/deferred/ginkgo" - "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" - "github.com/formancehq/go-libs/v2/testing/testservice" + "github.com/formancehq/go-libs/v3/logging" + . "github.com/formancehq/go-libs/v3/testing/deferred/ginkgo" + "github.com/formancehq/go-libs/v3/testing/platform/pgtesting" + "github.com/formancehq/go-libs/v3/testing/testservice" "github.com/formancehq/ledger/pkg/client/models/operations" . "github.com/formancehq/ledger/pkg/testserver" "github.com/formancehq/ledger/pkg/testserver/ginkgo" diff --git a/test/e2e/api_logs_list_test.go b/test/e2e/api_logs_list_test.go index 7c30b18e7b..d8fbc0629b 100644 --- a/test/e2e/api_logs_list_test.go +++ b/test/e2e/api_logs_list_test.go @@ -4,11 +4,11 @@ package test_suite import ( "fmt" - "github.com/formancehq/go-libs/v2/logging" - "github.com/formancehq/go-libs/v2/pointer" - . "github.com/formancehq/go-libs/v2/testing/deferred/ginkgo" - "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" - "github.com/formancehq/go-libs/v2/testing/testservice" + "github.com/formancehq/go-libs/v3/logging" + "github.com/formancehq/go-libs/v3/pointer" + . "github.com/formancehq/go-libs/v3/testing/deferred/ginkgo" + "github.com/formancehq/go-libs/v3/testing/platform/pgtesting" + "github.com/formancehq/go-libs/v3/testing/testservice" "github.com/formancehq/ledger/pkg/client/models/components" "github.com/formancehq/ledger/pkg/client/models/operations" . "github.com/formancehq/ledger/pkg/testserver" diff --git a/test/e2e/api_transactions_create_test.go b/test/e2e/api_transactions_create_test.go index 9f2e55c1ff..7bc0d82de7 100644 --- a/test/e2e/api_transactions_create_test.go +++ b/test/e2e/api_transactions_create_test.go @@ -3,25 +3,25 @@ package test_suite import ( - "github.com/formancehq/go-libs/v2/testing/deferred/ginkgo" - . "github.com/formancehq/go-libs/v2/testing/deferred/ginkgo" - "github.com/formancehq/go-libs/v2/testing/platform/natstesting" - "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" - "github.com/formancehq/go-libs/v2/testing/testservice" + "github.com/formancehq/go-libs/v3/testing/deferred/ginkgo" + . "github.com/formancehq/go-libs/v3/testing/deferred/ginkgo" + "github.com/formancehq/go-libs/v3/testing/platform/natstesting" + "github.com/formancehq/go-libs/v3/testing/platform/pgtesting" + "github.com/formancehq/go-libs/v3/testing/testservice" . "github.com/formancehq/ledger/pkg/testserver/ginkgo" "math/big" "time" - "github.com/formancehq/go-libs/v2/logging" - . "github.com/formancehq/go-libs/v2/testing/api" + "github.com/formancehq/go-libs/v3/logging" + . "github.com/formancehq/go-libs/v3/testing/api" ledger "github.com/formancehq/ledger/internal" "github.com/formancehq/ledger/internal/bus" "github.com/formancehq/ledger/pkg/client/models/components" "github.com/formancehq/ledger/pkg/client/models/operations" . "github.com/formancehq/ledger/pkg/testserver" - "github.com/formancehq/go-libs/v2/metadata" - "github.com/formancehq/go-libs/v2/pointer" + "github.com/formancehq/go-libs/v3/metadata" + "github.com/formancehq/go-libs/v3/pointer" ledgerevents "github.com/formancehq/ledger/pkg/events" "github.com/nats-io/nats.go" . "github.com/onsi/ginkgo/v2" diff --git a/test/e2e/api_transactions_list_test.go b/test/e2e/api_transactions_list_test.go index 14aacb068b..bb84c9c2de 100644 --- a/test/e2e/api_transactions_list_test.go +++ b/test/e2e/api_transactions_list_test.go @@ -4,14 +4,14 @@ package test_suite import ( "fmt" - "github.com/formancehq/go-libs/v2/bun/bunpaginate" - "github.com/formancehq/go-libs/v2/logging" - "github.com/formancehq/go-libs/v2/query" - . "github.com/formancehq/go-libs/v2/testing/api" - . "github.com/formancehq/go-libs/v2/testing/deferred/ginkgo" - "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" - "github.com/formancehq/go-libs/v2/testing/testservice" - libtime "github.com/formancehq/go-libs/v2/time" + "github.com/formancehq/go-libs/v3/bun/bunpaginate" + "github.com/formancehq/go-libs/v3/logging" + "github.com/formancehq/go-libs/v3/query" + . "github.com/formancehq/go-libs/v3/testing/api" + . "github.com/formancehq/go-libs/v3/testing/deferred/ginkgo" + "github.com/formancehq/go-libs/v3/testing/platform/pgtesting" + "github.com/formancehq/go-libs/v3/testing/testservice" + libtime "github.com/formancehq/go-libs/v3/time" "github.com/formancehq/ledger/internal/storage/common" "github.com/formancehq/ledger/pkg/client/models/components" "github.com/formancehq/ledger/pkg/client/models/operations" @@ -23,8 +23,8 @@ import ( "sort" "time" - "github.com/formancehq/go-libs/v2/metadata" - "github.com/formancehq/go-libs/v2/pointer" + "github.com/formancehq/go-libs/v3/metadata" + "github.com/formancehq/go-libs/v3/pointer" ) var _ = Context("Ledger transactions list API tests", func() { diff --git a/test/e2e/api_transactions_metadata_test.go b/test/e2e/api_transactions_metadata_test.go index 80d1326b52..ceee85c313 100644 --- a/test/e2e/api_transactions_metadata_test.go +++ b/test/e2e/api_transactions_metadata_test.go @@ -3,11 +3,11 @@ package test_suite import ( - "github.com/formancehq/go-libs/v2/logging" - . "github.com/formancehq/go-libs/v2/testing/api" - . "github.com/formancehq/go-libs/v2/testing/deferred/ginkgo" - "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" - "github.com/formancehq/go-libs/v2/testing/testservice" + "github.com/formancehq/go-libs/v3/logging" + . "github.com/formancehq/go-libs/v3/testing/api" + . "github.com/formancehq/go-libs/v3/testing/deferred/ginkgo" + "github.com/formancehq/go-libs/v3/testing/platform/pgtesting" + "github.com/formancehq/go-libs/v3/testing/testservice" "github.com/formancehq/ledger/pkg/client/models/components" "github.com/formancehq/ledger/pkg/client/models/operations" . "github.com/formancehq/ledger/pkg/testserver" diff --git a/test/e2e/api_transactions_revert_test.go b/test/e2e/api_transactions_revert_test.go index 25086faf35..eba1e7828b 100644 --- a/test/e2e/api_transactions_revert_test.go +++ b/test/e2e/api_transactions_revert_test.go @@ -3,22 +3,22 @@ package test_suite import ( - "github.com/formancehq/go-libs/v2/testing/deferred/ginkgo" - . "github.com/formancehq/go-libs/v2/testing/deferred/ginkgo" - "github.com/formancehq/go-libs/v2/testing/platform/natstesting" - "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" - "github.com/formancehq/go-libs/v2/testing/testservice" + "github.com/formancehq/go-libs/v3/testing/deferred/ginkgo" + . "github.com/formancehq/go-libs/v3/testing/deferred/ginkgo" + "github.com/formancehq/go-libs/v3/testing/platform/natstesting" + "github.com/formancehq/go-libs/v3/testing/platform/pgtesting" + "github.com/formancehq/go-libs/v3/testing/testservice" . "github.com/formancehq/ledger/pkg/testserver/ginkgo" "math/big" "time" - "github.com/formancehq/go-libs/v2/logging" - . "github.com/formancehq/go-libs/v2/testing/api" + "github.com/formancehq/go-libs/v3/logging" + . "github.com/formancehq/go-libs/v3/testing/api" "github.com/formancehq/ledger/pkg/client/models/components" "github.com/formancehq/ledger/pkg/client/models/operations" . "github.com/formancehq/ledger/pkg/testserver" - "github.com/formancehq/go-libs/v2/pointer" + "github.com/formancehq/go-libs/v3/pointer" "github.com/nats-io/nats.go" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" diff --git a/test/e2e/api_volumes_test.go b/test/e2e/api_volumes_test.go index 779c1bd516..ebc865d730 100644 --- a/test/e2e/api_volumes_test.go +++ b/test/e2e/api_volumes_test.go @@ -3,11 +3,11 @@ package test_suite import ( - "github.com/formancehq/go-libs/v2/logging" - "github.com/formancehq/go-libs/v2/pointer" - . "github.com/formancehq/go-libs/v2/testing/deferred/ginkgo" - "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" - "github.com/formancehq/go-libs/v2/testing/testservice" + "github.com/formancehq/go-libs/v3/logging" + "github.com/formancehq/go-libs/v3/pointer" + . "github.com/formancehq/go-libs/v3/testing/deferred/ginkgo" + "github.com/formancehq/go-libs/v3/testing/platform/pgtesting" + "github.com/formancehq/go-libs/v3/testing/testservice" "github.com/formancehq/ledger/pkg/client/models/components" "github.com/formancehq/ledger/pkg/client/models/operations" . "github.com/formancehq/ledger/pkg/testserver" diff --git a/test/e2e/app_lifecycle_test.go b/test/e2e/app_lifecycle_test.go index 93523bbc6a..cbc4c5c569 100644 --- a/test/e2e/app_lifecycle_test.go +++ b/test/e2e/app_lifecycle_test.go @@ -6,14 +6,14 @@ import ( "context" "database/sql" "encoding/json" - "github.com/formancehq/go-libs/v2/bun/bunconnect" - "github.com/formancehq/go-libs/v2/logging" - "github.com/formancehq/go-libs/v2/pointer" - . "github.com/formancehq/go-libs/v2/testing/deferred/ginkgo" - "github.com/formancehq/go-libs/v2/testing/platform/natstesting" - "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" - "github.com/formancehq/go-libs/v2/testing/testservice" - "github.com/formancehq/go-libs/v2/time" + "github.com/formancehq/go-libs/v3/bun/bunconnect" + "github.com/formancehq/go-libs/v3/logging" + "github.com/formancehq/go-libs/v3/pointer" + . "github.com/formancehq/go-libs/v3/testing/deferred/ginkgo" + "github.com/formancehq/go-libs/v3/testing/platform/natstesting" + "github.com/formancehq/go-libs/v3/testing/platform/pgtesting" + "github.com/formancehq/go-libs/v3/testing/testservice" + "github.com/formancehq/go-libs/v3/time" ledger "github.com/formancehq/ledger/internal" "github.com/formancehq/ledger/internal/storage" "github.com/formancehq/ledger/internal/storage/bucket" diff --git a/test/e2e/app_logs_blocks_async_test.go b/test/e2e/app_logs_blocks_async_test.go index 67556f547e..edca0065c4 100644 --- a/test/e2e/app_logs_blocks_async_test.go +++ b/test/e2e/app_logs_blocks_async_test.go @@ -4,11 +4,11 @@ package test_suite import ( "fmt" - "github.com/formancehq/go-libs/v2/logging" - "github.com/formancehq/go-libs/v2/pointer" - . "github.com/formancehq/go-libs/v2/testing/deferred/ginkgo" - "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" - "github.com/formancehq/go-libs/v2/testing/testservice" + "github.com/formancehq/go-libs/v3/logging" + "github.com/formancehq/go-libs/v3/pointer" + . "github.com/formancehq/go-libs/v3/testing/deferred/ginkgo" + "github.com/formancehq/go-libs/v3/testing/platform/pgtesting" + "github.com/formancehq/go-libs/v3/testing/testservice" "github.com/formancehq/ledger/pkg/client/models/components" "github.com/formancehq/ledger/pkg/client/models/operations" "github.com/formancehq/ledger/pkg/features" diff --git a/test/e2e/app_multiple_instance_test.go b/test/e2e/app_multiple_instance_test.go index 780abc96e5..0351a550eb 100644 --- a/test/e2e/app_multiple_instance_test.go +++ b/test/e2e/app_multiple_instance_test.go @@ -3,10 +3,10 @@ package test_suite import ( - "github.com/formancehq/go-libs/v2/logging" - "github.com/formancehq/go-libs/v2/testing/deferred" - "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" - "github.com/formancehq/go-libs/v2/testing/testservice" + "github.com/formancehq/go-libs/v3/logging" + "github.com/formancehq/go-libs/v3/testing/deferred" + "github.com/formancehq/go-libs/v3/testing/platform/pgtesting" + "github.com/formancehq/go-libs/v3/testing/testservice" "github.com/formancehq/ledger/cmd" . "github.com/formancehq/ledger/pkg/testserver" . "github.com/onsi/ginkgo/v2" diff --git a/test/e2e/suite_test.go b/test/e2e/suite_test.go index 388c44038a..f8393957f9 100644 --- a/test/e2e/suite_test.go +++ b/test/e2e/suite_test.go @@ -5,10 +5,10 @@ package test_suite import ( "context" "encoding/json" - "github.com/formancehq/go-libs/v2/bun/bunconnect" - "github.com/formancehq/go-libs/v2/testing/deferred" - "github.com/formancehq/go-libs/v2/testing/platform/natstesting" - "github.com/formancehq/go-libs/v2/testing/testservice" + "github.com/formancehq/go-libs/v3/bun/bunconnect" + "github.com/formancehq/go-libs/v3/testing/deferred" + "github.com/formancehq/go-libs/v3/testing/platform/natstesting" + "github.com/formancehq/go-libs/v3/testing/testservice" ledger "github.com/formancehq/ledger/internal" "github.com/formancehq/ledger/internal/storage/bucket" "github.com/formancehq/ledger/internal/storage/system" @@ -17,9 +17,9 @@ import ( "os" "testing" - "github.com/formancehq/go-libs/v2/logging" - "github.com/formancehq/go-libs/v2/testing/docker" - . "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" + "github.com/formancehq/go-libs/v3/logging" + "github.com/formancehq/go-libs/v3/testing/docker" + . "github.com/formancehq/go-libs/v3/testing/platform/pgtesting" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/test/e2e/v1_api_balances_test.go b/test/e2e/v1_api_balances_test.go index 20b7652389..c04de5071b 100644 --- a/test/e2e/v1_api_balances_test.go +++ b/test/e2e/v1_api_balances_test.go @@ -4,11 +4,11 @@ package test_suite import ( "fmt" - "github.com/formancehq/go-libs/v2/logging" - "github.com/formancehq/go-libs/v2/pointer" - . "github.com/formancehq/go-libs/v2/testing/deferred/ginkgo" - "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" - "github.com/formancehq/go-libs/v2/testing/testservice" + "github.com/formancehq/go-libs/v3/logging" + "github.com/formancehq/go-libs/v3/pointer" + . "github.com/formancehq/go-libs/v3/testing/deferred/ginkgo" + "github.com/formancehq/go-libs/v3/testing/platform/pgtesting" + "github.com/formancehq/go-libs/v3/testing/testservice" "github.com/formancehq/ledger/pkg/client/models/components" "github.com/formancehq/ledger/pkg/client/models/operations" . "github.com/formancehq/ledger/pkg/testserver" diff --git a/test/migrations/upgrade_test.go b/test/migrations/upgrade_test.go index 5303464198..92c4bfb4c5 100644 --- a/test/migrations/upgrade_test.go +++ b/test/migrations/upgrade_test.go @@ -3,10 +3,10 @@ package migrations import ( "flag" "fmt" - "github.com/formancehq/go-libs/v2/bun/bunconnect" - "github.com/formancehq/go-libs/v2/logging" - "github.com/formancehq/go-libs/v2/testing/docker" - "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" + "github.com/formancehq/go-libs/v3/bun/bunconnect" + "github.com/formancehq/go-libs/v3/logging" + "github.com/formancehq/go-libs/v3/testing/docker" + "github.com/formancehq/go-libs/v3/testing/platform/pgtesting" "github.com/formancehq/ledger/internal/storage/bucket" "github.com/formancehq/ledger/internal/storage/driver" "github.com/formancehq/ledger/internal/storage/ledger" diff --git a/test/performance/pkg/env/configure.go b/test/performance/pkg/env/configure.go index 96223fa59c..56d65508bc 100644 --- a/test/performance/pkg/env/configure.go +++ b/test/performance/pkg/env/configure.go @@ -7,7 +7,7 @@ import ( "crypto/tls" "flag" "fmt" - "github.com/formancehq/go-libs/v2/httpclient" + "github.com/formancehq/go-libs/v3/httpclient" "golang.org/x/oauth2" "golang.org/x/oauth2/clientcredentials" "net/http" diff --git a/test/performance/pkg/env/features.go b/test/performance/pkg/env/features.go index be83ff6354..b266041773 100644 --- a/test/performance/pkg/env/features.go +++ b/test/performance/pkg/env/features.go @@ -3,7 +3,7 @@ package env import ( - . "github.com/formancehq/go-libs/v2/collectionutils" + . "github.com/formancehq/go-libs/v3/collectionutils" "github.com/formancehq/ledger/pkg/features" "sort" ) diff --git a/test/performance/pkg/read/read_test.go b/test/performance/pkg/read/read_test.go index 7a106aea06..e48648437c 100644 --- a/test/performance/pkg/read/read_test.go +++ b/test/performance/pkg/read/read_test.go @@ -6,8 +6,8 @@ import ( "context" "flag" "fmt" - "github.com/formancehq/go-libs/v2/logging" - "github.com/formancehq/go-libs/v2/pointer" + "github.com/formancehq/go-libs/v3/logging" + "github.com/formancehq/go-libs/v3/pointer" "github.com/formancehq/ledger/pkg/client/models/operations" "github.com/formancehq/ledger/test/performance/pkg/env" "github.com/stretchr/testify/require" diff --git a/test/performance/pkg/write/local_env_test.go b/test/performance/pkg/write/local_env_test.go index 11ad7941cd..a271d886e7 100644 --- a/test/performance/pkg/write/local_env_test.go +++ b/test/performance/pkg/write/local_env_test.go @@ -4,11 +4,11 @@ package write import ( "context" - "github.com/formancehq/go-libs/v2/logging" - "github.com/formancehq/go-libs/v2/otlp/otlpmetrics" - "github.com/formancehq/go-libs/v2/testing/docker" - "github.com/formancehq/go-libs/v2/testing/testservice" - . "github.com/formancehq/go-libs/v2/testing/utils" + "github.com/formancehq/go-libs/v3/logging" + "github.com/formancehq/go-libs/v3/otlp/otlpmetrics" + "github.com/formancehq/go-libs/v3/testing/docker" + "github.com/formancehq/go-libs/v3/testing/testservice" + . "github.com/formancehq/go-libs/v3/testing/utils" ledgerclient "github.com/formancehq/ledger/pkg/client" "github.com/formancehq/ledger/test/performance/pkg/env" "io" @@ -16,8 +16,8 @@ import ( "os" "testing" - "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" - "github.com/formancehq/go-libs/v2/time" + "github.com/formancehq/go-libs/v3/testing/platform/pgtesting" + "github.com/formancehq/go-libs/v3/time" "github.com/formancehq/ledger/pkg/testserver" ) diff --git a/test/performance/pkg/write/report_test.go b/test/performance/pkg/write/report_test.go index c55997c68f..f713e9f0d3 100644 --- a/test/performance/pkg/write/report_test.go +++ b/test/performance/pkg/write/report_test.go @@ -3,7 +3,7 @@ package write_test import ( - "github.com/formancehq/go-libs/v2/time" + "github.com/formancehq/go-libs/v3/time" "github.com/formancehq/ledger/test/performance/pkg/env" "github.com/jamiealquiza/tachymeter" "sync" diff --git a/test/performance/pkg/write/write_test.go b/test/performance/pkg/write/write_test.go index aa7f602cf4..7ccf87a24b 100644 --- a/test/performance/pkg/write/write_test.go +++ b/test/performance/pkg/write/write_test.go @@ -8,9 +8,9 @@ import ( "encoding/json" "flag" "fmt" - . "github.com/formancehq/go-libs/v2/collectionutils" - "github.com/formancehq/go-libs/v2/logging" - "github.com/formancehq/go-libs/v2/time" + . "github.com/formancehq/go-libs/v3/collectionutils" + "github.com/formancehq/go-libs/v3/logging" + "github.com/formancehq/go-libs/v3/time" ledger "github.com/formancehq/ledger/internal" "github.com/formancehq/ledger/pkg/client/models/components" "github.com/formancehq/ledger/pkg/client/models/operations" diff --git a/test/stress/stress_test.go b/test/stress/stress_test.go index e97023e9c2..c869bed4ed 100644 --- a/test/stress/stress_test.go +++ b/test/stress/stress_test.go @@ -4,8 +4,8 @@ package test_suite import ( "fmt" - . "github.com/formancehq/go-libs/v2/testing/deferred/ginkgo" - "github.com/formancehq/go-libs/v2/testing/testservice" + . "github.com/formancehq/go-libs/v3/testing/deferred/ginkgo" + "github.com/formancehq/go-libs/v3/testing/testservice" "github.com/formancehq/ledger/pkg/features" . "github.com/formancehq/ledger/pkg/testserver/ginkgo" "math/big" @@ -14,9 +14,9 @@ import ( "sync/atomic" "github.com/alitto/pond" - "github.com/formancehq/go-libs/v2/logging" - "github.com/formancehq/go-libs/v2/pointer" - "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" + "github.com/formancehq/go-libs/v3/logging" + "github.com/formancehq/go-libs/v3/pointer" + "github.com/formancehq/go-libs/v3/testing/platform/pgtesting" "github.com/formancehq/ledger/pkg/client/models/components" "github.com/formancehq/ledger/pkg/client/models/operations" . "github.com/formancehq/ledger/pkg/testserver" diff --git a/test/stress/suite_test.go b/test/stress/suite_test.go index 111420812a..53684692b6 100644 --- a/test/stress/suite_test.go +++ b/test/stress/suite_test.go @@ -4,13 +4,13 @@ package test_suite import ( "encoding/json" - "github.com/formancehq/go-libs/v2/testing/deferred" - . "github.com/formancehq/go-libs/v2/testing/platform/pgtesting" + "github.com/formancehq/go-libs/v3/testing/deferred" + . "github.com/formancehq/go-libs/v3/testing/platform/pgtesting" "os" "testing" - "github.com/formancehq/go-libs/v2/logging" - "github.com/formancehq/go-libs/v2/testing/docker" + "github.com/formancehq/go-libs/v3/logging" + "github.com/formancehq/go-libs/v3/testing/docker" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/tools/generator/cmd/root.go b/tools/generator/cmd/root.go index 79968cf488..3825417726 100644 --- a/tools/generator/cmd/root.go +++ b/tools/generator/cmd/root.go @@ -5,7 +5,7 @@ import ( "crypto/tls" "errors" "fmt" - "github.com/formancehq/go-libs/v2/logging" + "github.com/formancehq/go-libs/v3/logging" ledgerclient "github.com/formancehq/ledger/pkg/client" "github.com/formancehq/ledger/pkg/client/models/components" "github.com/formancehq/ledger/pkg/client/models/operations" diff --git a/tools/generator/go.mod b/tools/generator/go.mod index 63cdfb2f56..25f7807dab 100644 --- a/tools/generator/go.mod +++ b/tools/generator/go.mod @@ -9,7 +9,7 @@ replace github.com/formancehq/ledger => ../.. replace github.com/formancehq/ledger/pkg/client => ../../pkg/client require ( - github.com/formancehq/go-libs/v2 v2.2.3-0.20250404150347-dfce43bb3362 + github.com/formancehq/go-libs/v3 v3.0.0-20250408113106-7b3525e0b25b github.com/formancehq/ledger v0.0.0-00010101000000-000000000000 github.com/formancehq/ledger/pkg/client v0.0.0-00010101000000-000000000000 github.com/spf13/cobra v1.9.1 diff --git a/tools/generator/go.sum b/tools/generator/go.sum index 101cbfd72e..6b72af4674 100644 --- a/tools/generator/go.sum +++ b/tools/generator/go.sum @@ -102,8 +102,8 @@ github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= -github.com/formancehq/go-libs/v2 v2.2.3-0.20250404150347-dfce43bb3362 h1:UN4aVIj4qnzAeYEoz6mvWaAPWvx+CO+HXFEWac/8cv4= -github.com/formancehq/go-libs/v2 v2.2.3-0.20250404150347-dfce43bb3362/go.mod h1:to6sgzwqspeTKlAF0Vdj/13EMHc8oYNc2gJfxf7hrt8= +github.com/formancehq/go-libs/v3 v3.0.0-20250408113106-7b3525e0b25b h1:EvnYMGyZo+fq9fsrraedKBlVTbeE2mqpJ/edj8FRTtU= +github.com/formancehq/go-libs/v3 v3.0.0-20250408113106-7b3525e0b25b/go.mod h1:mRr5/y0I64iJ4I+BXNkUy49izwrh3SA5L+MTWD1d/7Q= github.com/formancehq/numscript v0.0.15 h1:dprjzbPWWPvIYM1o9P4Ppb6LKs4UuZw3AYeHy78b06k= github.com/formancehq/numscript v0.0.15/go.mod h1:P8qnq15PyWUuhskZdsrzTTqVS5CBkhakDKEPAyF4oYQ= github.com/fsnotify/fsnotify v1.8.0 h1:dAwr6QBTBZIkG8roQaJjGof0pp0EeF+tNV7YBP3F/8M= diff --git a/tools/provisioner/go.mod b/tools/provisioner/go.mod index c6bc9c7bdf..de7977a4f4 100644 --- a/tools/provisioner/go.mod +++ b/tools/provisioner/go.mod @@ -5,9 +5,9 @@ go 1.23.3 replace github.com/formancehq/ledger/pkg/client => ../../pkg/client require ( - github.com/formancehq/go-libs/v2 v2.2.2 + github.com/formancehq/go-libs/v3 v3.0.0-20250407134146-8be8ce3ddc42 github.com/formancehq/ledger/pkg/client v0.0.0-00010101000000-000000000000 - github.com/google/go-cmp v0.6.0 + github.com/google/go-cmp v0.7.0 github.com/spf13/cobra v1.9.1 gopkg.in/yaml.v2 v2.4.0 gopkg.in/yaml.v3 v3.0.1 diff --git a/tools/provisioner/go.sum b/tools/provisioner/go.sum index 91b9fb47d4..41ccad0f30 100644 --- a/tools/provisioner/go.sum +++ b/tools/provisioner/go.sum @@ -8,8 +8,8 @@ github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxER github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/ericlagergren/decimal v0.0.0-20221120152707-495c53812d05 h1:S92OBrGuLLZsyM5ybUzgc/mPjIYk2AZqufieooe98uw= github.com/ericlagergren/decimal v0.0.0-20221120152707-495c53812d05/go.mod h1:M9R1FoZ3y//hwwnJtO51ypFGwm8ZfpxPT/ZLtO1mcgQ= -github.com/formancehq/go-libs/v2 v2.2.2 h1:COVo8+wIybiiocw4NWl3W0dovQgkO/b/P1jTk1ItKGw= -github.com/formancehq/go-libs/v2 v2.2.2/go.mod h1:vIUz00DsuhjrRV7mimv3V/VXhYDRQXAEh2KWW16CAtM= +github.com/formancehq/go-libs/v3 v3.0.0-20250407134146-8be8ce3ddc42 h1:rFWfsfJ/7YDqGKWP611qB3GO/IfV4RFHC6QPYFYtwhc= +github.com/formancehq/go-libs/v3 v3.0.0-20250407134146-8be8ce3ddc42/go.mod h1:XkznJST08MyV+HzPYlpAUuzdm8GWXGYl80fOJdZpAzQ= github.com/fxamacker/cbor/v2 v2.7.0 h1:iM5WgngdRBanHcxugY4JySA0nk1wZorNOpTgCMedv5E= github.com/fxamacker/cbor/v2 v2.7.0/go.mod h1:pxXPTn3joSm21Gbwsv0w9OSA2y1HFR9qXEeXQVeNoDQ= github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= @@ -31,8 +31,8 @@ github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6 github.com/google/gnostic-models v0.6.8 h1:yo/ABAfM5IMRsS1VnXjTBvUb61tFIHozhlYvRgGre9I= github.com/google/gnostic-models v0.6.8/go.mod h1:5n7qKqH0f5wFt+aWF8CW6pZLLNOfYuF5OpfBSENuI8U= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= -github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= +github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= diff --git a/tools/provisioner/pkg/reconciler.go b/tools/provisioner/pkg/reconciler.go index f26b5671eb..18dcf944cc 100644 --- a/tools/provisioner/pkg/reconciler.go +++ b/tools/provisioner/pkg/reconciler.go @@ -3,7 +3,7 @@ package provisionner import ( "context" "fmt" - "github.com/formancehq/go-libs/v2/pointer" + "github.com/formancehq/go-libs/v3/pointer" "github.com/formancehq/ledger/pkg/client" "github.com/formancehq/ledger/pkg/client/models/components" "github.com/formancehq/ledger/pkg/client/models/operations" diff --git a/tools/provisioner/pkg/store.go b/tools/provisioner/pkg/store.go index e0f42ed71e..14a3eabe74 100644 --- a/tools/provisioner/pkg/store.go +++ b/tools/provisioner/pkg/store.go @@ -4,7 +4,7 @@ import ( "bytes" "context" "errors" - "github.com/formancehq/go-libs/v2/pointer" + "github.com/formancehq/go-libs/v3/pointer" "gopkg.in/yaml.v3" v1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors"