diff --git a/components/fctl/cmd/payments/accounts/list.go b/components/fctl/cmd/payments/accounts/list.go index 12b63bf4fd..842686c42c 100644 --- a/components/fctl/cmd/payments/accounts/list.go +++ b/components/fctl/cmd/payments/accounts/list.go @@ -12,7 +12,7 @@ import ( ) type ListStore struct { - Cursor *shared.AccountsCursorCursor `json:"cursor"` + Cursor *shared.Cursor `json:"cursor"` } type ListController struct { @@ -26,7 +26,7 @@ var _ fctl.Controller[*ListStore] = (*ListController)(nil) func NewListStore() *ListStore { return &ListStore{ - Cursor: &shared.AccountsCursorCursor{}, + Cursor: &shared.Cursor{}, } } diff --git a/components/fctl/cmd/payments/transferinitiation/update_status.go b/components/fctl/cmd/payments/transferinitiation/update_status.go index 0c7944b89d..498385bb21 100644 --- a/components/fctl/cmd/payments/transferinitiation/update_status.go +++ b/components/fctl/cmd/payments/transferinitiation/update_status.go @@ -80,7 +80,7 @@ func (c *UpdateStatusController) Run(cmd *cobra.Command, args []string) (fctl.Re //nolint:gosimple response, err := client.Payments.UdpateTransferInitiationStatus(cmd.Context(), operations.UdpateTransferInitiationStatusRequest{ UpdateTransferInitiationStatusRequest: shared.UpdateTransferInitiationStatusRequest{ - Status: shared.UpdateTransferInitiationStatusRequestStatus(args[1]), + Status: shared.Status(args[1]), }, TransferID: args[0], }) diff --git a/components/fctl/cmd/root.go b/components/fctl/cmd/root.go index 3b2c03b86c..469cd3e758 100644 --- a/components/fctl/cmd/root.go +++ b/components/fctl/cmd/root.go @@ -25,7 +25,7 @@ import ( "github.com/formancehq/fctl/cmd/webhooks" "github.com/formancehq/fctl/membershipclient" fctl "github.com/formancehq/fctl/pkg" - "github.com/formancehq/formance-sdk-go/pkg/models/shared" + "github.com/formancehq/formance-sdk-go/pkg/models/sdkerrors" "github.com/formancehq/stack/libs/go-libs/api" "github.com/pterm/pterm" "github.com/spf13/cobra" @@ -119,7 +119,7 @@ func extractOpenAPIErrorMessage(err error) error { return err } -func unwrapOpenAPIError(err error) *shared.V2ErrorResponse { +func unwrapOpenAPIError(err error) *sdkerrors.V2Error { openapiError := &membershipclient.GenericOpenAPIError{} if errors.As(err, &openapiError) { body := openapiError.Body() @@ -133,11 +133,9 @@ func unwrapOpenAPIError(err error) *shared.V2ErrorResponse { } if errResponse.ErrorCode != "" { - errorCode := shared.V2ErrorsEnum(errResponse.ErrorCode) - return &shared.V2ErrorResponse{ - ErrorCode: errorCode, + return &sdkerrors.V2Error{ + ErrorCode: sdkerrors.ErrorCode(errResponse.ErrorCode), ErrorMessage: errResponse.ErrorMessage, - Details: &errResponse.Details, } } } diff --git a/components/fctl/cmd/webhooks/delete.go b/components/fctl/cmd/webhooks/delete.go index 20739690fe..176e764551 100644 --- a/components/fctl/cmd/webhooks/delete.go +++ b/components/fctl/cmd/webhooks/delete.go @@ -5,15 +5,15 @@ import ( fctl "github.com/formancehq/fctl/pkg" "github.com/formancehq/formance-sdk-go/pkg/models/operations" - "github.com/formancehq/formance-sdk-go/pkg/models/shared" + "github.com/formancehq/formance-sdk-go/pkg/models/sdkerrors" "github.com/pkg/errors" "github.com/pterm/pterm" "github.com/spf13/cobra" ) type DeleteWebhookStore struct { - ErrorResponse *shared.WebhooksErrorResponse `json:"error"` - Success bool `json:"success"` + ErrorResponse *sdkerrors.WebhooksErrorResponse `json:"error"` + Success bool `json:"success"` } type DeleteWebhookController struct { diff --git a/ee/orchestration/internal/workflow/activities/activity_ledger_create_transaction.go b/ee/orchestration/internal/workflow/activities/activity_ledger_create_transaction.go index 3f4e84762a..849051d3fa 100644 --- a/ee/orchestration/internal/workflow/activities/activity_ledger_create_transaction.go +++ b/ee/orchestration/internal/workflow/activities/activity_ledger_create_transaction.go @@ -22,7 +22,7 @@ type CreateTransactionWrapper struct { // OK CreateTransactionResponse *CreateTransactionResponse // Error - ErrorResponse *shared.ErrorResponse + ErrorResponse *shared.Error StatusCode int RawResponse *http.Response } diff --git a/ee/wallets/pkg/api/handler_wallets_debit_test.go b/ee/wallets/pkg/api/handler_wallets_debit_test.go index 002beba86a..fd99f5e164 100644 --- a/ee/wallets/pkg/api/handler_wallets_debit_test.go +++ b/ee/wallets/pkg/api/handler_wallets_debit_test.go @@ -42,19 +42,17 @@ type testCase struct { } type apiErrorMock struct { - ErrorCode shared.ErrorsEnum `json:"errorCode,omitempty"` - ErrorMessage string `json:"errorMessage,omitempty"` - Details *string `json:"details,omitempty"` + ErrorCode shared.WalletsErrorResponseErrorCode `json:"errorCode,omitempty"` + ErrorMessage string `json:"errorMessage,omitempty"` } func (a *apiErrorMock) Model() any { if a == nil { return nil } - return shared.ErrorResponse{ + return shared.WalletsErrorResponse{ ErrorCode: a.ErrorCode, ErrorMessage: a.ErrorMessage, - Details: a.Details, } } @@ -141,7 +139,7 @@ var walletDebitTestCases = []testCase{ Amount: wallet.NewMonetary(big.NewInt(100), "USD"), }, postTransactionError: &apiErrorMock{ - ErrorCode: shared.ErrorsEnumInsufficientFund, + ErrorCode: shared.WalletsErrorResponseErrorCodeInsufficientFund, }, expectedStatusCode: http.StatusBadRequest, expectedErrorCode: string(shared.ErrorsEnumInsufficientFund), @@ -246,7 +244,7 @@ var walletDebitTestCases = []testCase{ } }, expectedStatusCode: http.StatusBadRequest, - expectedErrorCode: string(shared.ErrorErrorCodeValidation), + expectedErrorCode: string(shared.WalletsErrorResponseErrorCodeValidation), }, { name: "with custom balance as destination", diff --git a/ee/wallets/pkg/manager.go b/ee/wallets/pkg/manager.go index d3f1547ad7..15ae683ed6 100644 --- a/ee/wallets/pkg/manager.go +++ b/ee/wallets/pkg/manager.go @@ -288,10 +288,10 @@ func (m *Manager) CreateTransaction(ctx context.Context, postTransaction PostTra if _, err := m.client.CreateTransaction(ctx, m.ledgerName, postTransaction); err != nil { apiErr, ok := err.(GenericOpenAPIError) if ok { - respErr, ok := apiErr.Model().(shared.ErrorResponse) + respErr, ok := apiErr.Model().(shared.WalletsErrorResponse) if ok { switch respErr.ErrorCode { - case shared.ErrorsEnumInsufficientFund: + case shared.WalletsErrorResponseErrorCodeInsufficientFund: return ErrInsufficientFundError } } diff --git a/tests/integration/suite/ledger-aggregated-balances.go b/tests/integration/suite/ledger-aggregated-balances.go index 374a6683c2..01e83615f3 100644 --- a/tests/integration/suite/ledger-aggregated-balances.go +++ b/tests/integration/suite/ledger-aggregated-balances.go @@ -1,14 +1,15 @@ package suite import ( + "math/big" + "net/http" + "github.com/formancehq/formance-sdk-go/pkg/models/operations" "github.com/formancehq/formance-sdk-go/pkg/models/shared" . "github.com/formancehq/stack/tests/integration/internal" "github.com/formancehq/stack/tests/integration/internal/modules" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "math/big" - "net/http" ) var _ = WithModules([]*Module{modules.Ledger, modules.Search}, func() { @@ -22,7 +23,7 @@ var _ = WithModules([]*Module{modules.Ledger, modules.Search}, func() { _, err = Client().Ledger.V2CreateBulk(TestContext(), operations.V2CreateBulkRequest{ RequestBody: []shared.V2BulkElement{ - shared.CreateV2BulkElementCreateTransaction(shared.V2BulkElementV2BulkElementCreateTransaction{ + shared.CreateV2BulkElementCreateTransaction(shared.V2BulkElementCreateTransaction{ Data: &shared.V2PostTransaction{ Metadata: map[string]string{}, Postings: []shared.V2Posting{{ @@ -33,7 +34,7 @@ var _ = WithModules([]*Module{modules.Ledger, modules.Search}, func() { }}, }, }), - shared.CreateV2BulkElementCreateTransaction(shared.V2BulkElementV2BulkElementCreateTransaction{ + shared.CreateV2BulkElementCreateTransaction(shared.V2BulkElementCreateTransaction{ Data: &shared.V2PostTransaction{ Metadata: map[string]string{}, Postings: []shared.V2Posting{{ @@ -44,8 +45,8 @@ var _ = WithModules([]*Module{modules.Ledger, modules.Search}, func() { }}, }, }), - shared.CreateV2BulkElementAddMetadata(shared.V2BulkElementV2BulkElementAddMetadata{ - Data: &shared.V2BulkElementV2BulkElementAddMetadataData{ + shared.CreateV2BulkElementAddMetadata(shared.V2BulkElementAddMetadata{ + Data: &shared.V2BulkElementAddMetadataData{ Metadata: map[string]string{ "category": "premium", }, @@ -53,8 +54,8 @@ var _ = WithModules([]*Module{modules.Ledger, modules.Search}, func() { TargetType: shared.V2TargetTypeAccount, }, }), - shared.CreateV2BulkElementAddMetadata(shared.V2BulkElementV2BulkElementAddMetadata{ - Data: &shared.V2BulkElementV2BulkElementAddMetadataData{ + shared.CreateV2BulkElementAddMetadata(shared.V2BulkElementAddMetadata{ + Data: &shared.V2BulkElementAddMetadataData{ Metadata: map[string]string{ "category": "premium", }, diff --git a/tests/integration/suite/ledger-create-bulk.go b/tests/integration/suite/ledger-create-bulk.go index d33c58132e..ef9e6c98d4 100644 --- a/tests/integration/suite/ledger-create-bulk.go +++ b/tests/integration/suite/ledger-create-bulk.go @@ -1,6 +1,10 @@ package suite import ( + "math/big" + "net/http" + "time" + "github.com/formancehq/formance-sdk-go/pkg/models/operations" "github.com/formancehq/formance-sdk-go/pkg/models/shared" "github.com/formancehq/stack/libs/go-libs/metadata" @@ -8,9 +12,6 @@ import ( "github.com/formancehq/stack/tests/integration/internal/modules" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "math/big" - "net/http" - "time" ) var _ = WithModules([]*Module{modules.Ledger}, func() { @@ -28,7 +29,7 @@ var _ = WithModules([]*Module{modules.Ledger}, func() { BeforeEach(func() { _, err := Client().Ledger.V2CreateBulk(TestContext(), operations.V2CreateBulkRequest{ RequestBody: []shared.V2BulkElement{ - shared.CreateV2BulkElementCreateTransaction(shared.V2BulkElementV2BulkElementCreateTransaction{ + shared.CreateV2BulkElementCreateTransaction(shared.V2BulkElementCreateTransaction{ Data: &shared.V2PostTransaction{ Metadata: map[string]string{}, Postings: []shared.V2Posting{{ @@ -40,8 +41,8 @@ var _ = WithModules([]*Module{modules.Ledger}, func() { Timestamp: &now, }, }), - shared.CreateV2BulkElementAddMetadata(shared.V2BulkElementV2BulkElementAddMetadata{ - Data: &shared.V2BulkElementV2BulkElementAddMetadataData{ + shared.CreateV2BulkElementAddMetadata(shared.V2BulkElementAddMetadata{ + Data: &shared.V2BulkElementAddMetadataData{ Metadata: metadata.Metadata{ "foo": "bar", "role": "admin", @@ -50,15 +51,15 @@ var _ = WithModules([]*Module{modules.Ledger}, func() { TargetType: shared.V2TargetTypeTransaction, }, }), - shared.CreateV2BulkElementDeleteMetadata(shared.V2BulkElementV2BulkElementDeleteMetadata{ - Data: &shared.V2BulkElementV2BulkElementDeleteMetadataData{ + shared.CreateV2BulkElementDeleteMetadata(shared.V2BulkElementDeleteMetadata{ + Data: &shared.V2BulkElementDeleteMetadataData{ Key: "foo", TargetID: shared.CreateV2TargetIDBigint(big.NewInt(0)), TargetType: shared.V2TargetTypeTransaction, }, }), - shared.CreateV2BulkElementRevertTransaction(shared.V2BulkElementV2BulkElementRevertTransaction{ - Data: &shared.V2BulkElementV2BulkElementRevertTransactionData{ + shared.CreateV2BulkElementRevertTransaction(shared.V2BulkElementRevertTransaction{ + Data: &shared.V2BulkElementRevertTransactionData{ ID: big.NewInt(0), }, }), @@ -98,7 +99,7 @@ var _ = WithModules([]*Module{modules.Ledger}, func() { BeforeEach(func() { bulkResponse, err = Client().Ledger.V2CreateBulk(TestContext(), operations.V2CreateBulkRequest{ RequestBody: []shared.V2BulkElement{ - shared.CreateV2BulkElementCreateTransaction(shared.V2BulkElementV2BulkElementCreateTransaction{ + shared.CreateV2BulkElementCreateTransaction(shared.V2BulkElementCreateTransaction{ Data: &shared.V2PostTransaction{ Metadata: map[string]string{}, Postings: []shared.V2Posting{{ @@ -110,7 +111,7 @@ var _ = WithModules([]*Module{modules.Ledger}, func() { Timestamp: &now, }, }), - shared.CreateV2BulkElementCreateTransaction(shared.V2BulkElementV2BulkElementCreateTransaction{ + shared.CreateV2BulkElementCreateTransaction(shared.V2BulkElementCreateTransaction{ Data: &shared.V2PostTransaction{ Metadata: map[string]string{}, Postings: []shared.V2Posting{{ @@ -129,7 +130,7 @@ var _ = WithModules([]*Module{modules.Ledger}, func() { }) It("should respond with an error", func() { Expect(bulkResponse.V2BulkResponse.Data[1].Type).To(Equal(shared.V2BulkElementResultType("ERROR"))) - Expect(bulkResponse.V2BulkResponse.Data[1].V2BulkElementResultV2BulkElementResultError.ErrorCode).To(Equal("INSUFFICIENT_FUND")) + Expect(bulkResponse.V2BulkResponse.Data[1].V2BulkElementResultErrorSchemas.ErrorCode).To(Equal("INSUFFICIENT_FUND")) }) }) }) diff --git a/tests/integration/suite/ledger-create-transaction.go b/tests/integration/suite/ledger-create-transaction.go index 2267a29946..2a94650d0a 100644 --- a/tests/integration/suite/ledger-create-transaction.go +++ b/tests/integration/suite/ledger-create-transaction.go @@ -1,12 +1,13 @@ package suite import ( - "github.com/formancehq/formance-sdk-go/pkg/models/sdkerrors" - "github.com/formancehq/stack/tests/integration/internal/modules" "math/big" "net/http" "time" + "github.com/formancehq/formance-sdk-go/pkg/models/sdkerrors" + "github.com/formancehq/stack/tests/integration/internal/modules" + "github.com/formancehq/formance-sdk-go/pkg/models/operations" "github.com/formancehq/formance-sdk-go/pkg/models/shared" ledgerevents "github.com/formancehq/ledger/pkg/events" @@ -170,9 +171,9 @@ var _ = WithModules([]*Module{modules.Search, modules.Ledger}, func() { }, ) Expect(err).To(HaveOccurred()) - Expect(err.(*sdkerrors.V2ErrorResponse).ErrorCode).To(Equal(sdkerrors.V2ErrorsEnumConflict)) + Expect(err.(*sdkerrors.V2ErrorResponse).ErrorCode).To(Equal(shared.V2ErrorsEnumConflict)) }) - It("Should fail with "+string(sdkerrors.V2ErrorsEnumConflict)+" error code", func() {}) + It("Should fail with "+string(shared.V2ErrorsEnumConflict)+" error code", func() {}) }) It("should trigger a new event", func() { // Wait for created transaction event @@ -279,7 +280,7 @@ var _ = WithModules([]*Module{modules.Search, modules.Ledger}, func() { Expect(err).To(HaveOccurred()) Expect(err).Should(Equal(&sdkerrors.V2ErrorResponse{ - ErrorCode: sdkerrors.V2ErrorsEnumInsufficientFund, + ErrorCode: shared.V2ErrorsEnumInsufficientFund, ErrorMessage: "running numscript: script execution failed: no more fund to withdraw", })) }) @@ -347,9 +348,9 @@ var _ = WithModules([]*Module{modules.Search, modules.Ledger}, func() { }, ) }) - It("should fail with "+string(sdkerrors.V2ErrorsEnumCompilationFailed)+" code", func() { + It("should fail with "+string(shared.V2ErrorsEnumCompilationFailed)+" code", func() { Expect(err).NotTo(Succeed()) - Expect(err.(*sdkerrors.V2ErrorResponse).ErrorCode).To(Equal(sdkerrors.V2ErrorsEnumCompilationFailed)) + Expect(err.(*sdkerrors.V2ErrorResponse).ErrorCode).To(Equal(shared.V2ErrorsEnumCompilationFailed)) Expect(err.(*sdkerrors.V2ErrorResponse).Details).To(Equal(pointer.For("https://play.numscript.org/?payload=eyJlcnJvciI6Ilx1MDAxYlszMW0tLVx1MDAzZVx1MDAxYlswbSBlcnJvcjoxOjE1XHJcbiAgXHUwMDFiWzM0bXxcdTAwMWJbMG1cclxuXHUwMDFiWzMxbTEgfCBcdTAwMWJbMG1cdTAwMWJbOTBtc2VuZCBbQ09JTiAtMTAwXHUwMDFiWzBtXVx1MDAxYls5MG0gKFxyXG5cdTAwMWJbMG0gIFx1MDAxYlszNG18XHUwMDFiWzBtICAgICAgICAgICAgICAgIFx1MDAxYlszMW1eXHUwMDFiWzBtIG5vIHZpYWJsZSBhbHRlcm5hdGl2ZSBhdCBpbnB1dCAnW0NPSU4tMTAwXSdcclxuIn0="))) }) }) @@ -381,9 +382,9 @@ var _ = WithModules([]*Module{modules.Search, modules.Ledger}, func() { }, ) }) - It("should fail with "+string(sdkerrors.V2ErrorsEnumCompilationFailed)+" code", func() { + It("should fail with "+string(shared.V2ErrorsEnumCompilationFailed)+" code", func() { Expect(err).NotTo(Succeed()) - Expect(err.(*sdkerrors.V2ErrorResponse).ErrorCode).To(Equal(sdkerrors.V2ErrorsEnumCompilationFailed)) + Expect(err.(*sdkerrors.V2ErrorResponse).ErrorCode).To(Equal(shared.V2ErrorsEnumCompilationFailed)) Expect(err.(*sdkerrors.V2ErrorResponse).Details).To(Equal(pointer.For("https://play.numscript.org/?payload=eyJlcnJvciI6ImludmFsaWQgSlNPTiB2YWx1ZSBmb3IgdmFyaWFibGUgJGFtb3VudCBvZiB0eXBlIG1vbmV0YXJ5OiB2YWx1ZSBbVVNEIC0xMDBdOiBuZWdhdGl2ZSBhbW91bnQifQ=="))) }) }) @@ -407,9 +408,9 @@ var _ = WithModules([]*Module{modules.Search, modules.Ledger}, func() { }, ) }) - It("should fail with "+string(sdkerrors.V2ErrorsEnumCompilationFailed)+" code", func() { + It("should fail with "+string(shared.V2ErrorsEnumCompilationFailed)+" code", func() { Expect(err).NotTo(Succeed()) - Expect(err.(*sdkerrors.V2ErrorResponse).ErrorCode).To(Equal(sdkerrors.V2ErrorsEnumCompilationFailed)) + Expect(err.(*sdkerrors.V2ErrorResponse).ErrorCode).To(Equal(shared.V2ErrorsEnumCompilationFailed)) Expect(err.(*sdkerrors.V2ErrorResponse).Details).To(Equal(pointer.For("https://play.numscript.org/?payload=eyJlcnJvciI6Ilx1MDAxYlszMW0tLVx1MDAzZVx1MDAxYlswbSBlcnJvcjoxOjBcclxuICBcdTAwMWJbMzRtfFx1MDAxYlswbVxyXG5cdTAwMWJbMzFtMSB8IFx1MDAxYlswbVx1MDAxYls5MG1cdTAwMWJbMG1YWFhcdTAwMWJbOTBtXHJcblx1MDAxYlswbSAgXHUwMDFiWzM0bXxcdTAwMWJbMG0gXHUwMDFiWzMxbV5eXHUwMDFiWzBtIG1pc21hdGNoZWQgaW5wdXQgJ1hYWCcgZXhwZWN0aW5nIHtORVdMSU5FLCAndmFycycsICdzZXRfdHhfbWV0YScsICdzZXRfYWNjb3VudF9tZXRhJywgJ3ByaW50JywgJ2ZhaWwnLCAnc2VuZCcsICdzYXZlJ31cclxuIn0="))) }) }) @@ -439,9 +440,9 @@ var _ = WithModules([]*Module{modules.Search, modules.Ledger}, func() { }, ) }) - It("should fail with "+string(sdkerrors.V2ErrorsEnumNoPostings)+" code", func() { + It("should fail with "+string(shared.V2ErrorsEnumNoPostings)+" code", func() { Expect(err).NotTo(Succeed()) - Expect(err.(*sdkerrors.V2ErrorResponse).ErrorCode).To(Equal(sdkerrors.V2ErrorsEnumNoPostings)) + Expect(err.(*sdkerrors.V2ErrorResponse).ErrorCode).To(Equal(shared.V2ErrorsEnumNoPostings)) }) }) When("creating a transaction with metadata override", func() { @@ -470,9 +471,9 @@ var _ = WithModules([]*Module{modules.Search, modules.Ledger}, func() { }, ) }) - It("should fail with "+string(sdkerrors.V2ErrorsEnumMetadataOverride)+" code", func() { + It("should fail with "+string(shared.V2ErrorsEnumMetadataOverride)+" code", func() { Expect(err).NotTo(Succeed()) - Expect(err.(*sdkerrors.V2ErrorResponse).ErrorCode).To(Equal(sdkerrors.V2ErrorsEnumMetadataOverride)) + Expect(err.(*sdkerrors.V2ErrorResponse).ErrorCode).To(Equal(shared.V2ErrorsEnumMetadataOverride)) }) }) }) diff --git a/tests/integration/suite/ledger-create.go b/tests/integration/suite/ledger-create.go index f27fbe6ee0..4bf08c34a4 100644 --- a/tests/integration/suite/ledger-create.go +++ b/tests/integration/suite/ledger-create.go @@ -30,7 +30,7 @@ var _ = WithModules([]*Module{modules.Ledger}, func() { Ledger: "default", }) Expect(err).NotTo(BeNil()) - Expect(err.(*sdkerrors.V2ErrorResponse).ErrorCode).To(Equal(sdkerrors.V2ErrorsEnumValidation)) + Expect(err.(*sdkerrors.V2ErrorResponse).ErrorCode).To(Equal(shared.V2ErrorsEnumValidation)) }) It("should fail", func() {}) }) diff --git a/tests/integration/suite/ledger-list-count-accounts.go b/tests/integration/suite/ledger-list-count-accounts.go index 3d02dc0527..6055c9a262 100644 --- a/tests/integration/suite/ledger-list-count-accounts.go +++ b/tests/integration/suite/ledger-list-count-accounts.go @@ -2,14 +2,15 @@ package suite import ( "fmt" - "github.com/formancehq/formance-sdk-go/pkg/models/sdkerrors" - "github.com/formancehq/stack/libs/go-libs/pointer" - "github.com/formancehq/stack/tests/integration/internal/modules" "math/big" "net/http" "sort" "time" + "github.com/formancehq/formance-sdk-go/pkg/models/sdkerrors" + "github.com/formancehq/stack/libs/go-libs/pointer" + "github.com/formancehq/stack/tests/integration/internal/modules" + "github.com/formancehq/formance-sdk-go/pkg/models/operations" "github.com/formancehq/formance-sdk-go/pkg/models/shared" "github.com/formancehq/stack/libs/go-libs/metadata" @@ -97,7 +98,7 @@ var _ = WithModules([]*Module{modules.Ledger}, func() { }, ) Expect(err).To(HaveOccurred()) - Expect(err.(*sdkerrors.V2ErrorResponse).ErrorCode).To(Equal(sdkerrors.V2ErrorsEnumValidation)) + Expect(err.(*sdkerrors.V2ErrorResponse).ErrorCode).To(Equal(shared.V2ErrorsEnumValidation)) }) It("should be countable on api", func() { response, err := Client().Ledger.V2CountAccounts( diff --git a/tests/integration/suite/ledger-list-transactions.go b/tests/integration/suite/ledger-list-transactions.go index b2cdf62fb6..03db0db36a 100644 --- a/tests/integration/suite/ledger-list-transactions.go +++ b/tests/integration/suite/ledger-list-transactions.go @@ -2,12 +2,13 @@ package suite import ( "fmt" - "github.com/formancehq/formance-sdk-go/pkg/models/sdkerrors" - "github.com/formancehq/stack/tests/integration/internal/modules" "math/big" "net/http" "time" + "github.com/formancehq/formance-sdk-go/pkg/models/sdkerrors" + "github.com/formancehq/stack/tests/integration/internal/modules" + "github.com/formancehq/formance-sdk-go/pkg/models/operations" "github.com/formancehq/formance-sdk-go/pkg/models/shared" "github.com/formancehq/stack/libs/go-libs/metadata" @@ -24,7 +25,7 @@ var _ = WithModules([]*Module{modules.Ledger}, func() { Ledger: "default", }) Expect(err).NotTo(BeNil()) - Expect(err.(*sdkerrors.V2ErrorResponse).ErrorCode).To(Equal(sdkerrors.V2ErrorsEnumNotFound)) + Expect(err.(*sdkerrors.V2ErrorResponse).ErrorCode).To(Equal(shared.V2ErrorsEnumNotFound)) }) It("Should fail with a 404", func() { }) @@ -228,8 +229,8 @@ var _ = WithModules([]*Module{modules.Ledger}, func() { ) Expect(err).To(HaveOccurred()) }) - It("Should fail with "+string(sdkerrors.V2ErrorsEnumValidation)+" error code", func() { - Expect(err.(*sdkerrors.V2ErrorResponse).ErrorCode).To(Equal(sdkerrors.V2ErrorsEnumValidation)) + It("Should fail with "+string(shared.V2ErrorsEnumValidation)+" error code", func() { + Expect(err.(*sdkerrors.V2ErrorResponse).ErrorCode).To(Equal(shared.V2ErrorsEnumValidation)) }) }) }) @@ -988,7 +989,7 @@ var _ = WithModules([]*Module{modules.Ledger}, func() { }, ) Expect(err).To(HaveOccurred()) - Expect(err.(*sdkerrors.V2ErrorResponse).ErrorCode).To(Equal(sdkerrors.V2ErrorsEnumNotFound)) + Expect(err.(*sdkerrors.V2ErrorResponse).ErrorCode).To(Equal(shared.V2ErrorsEnumNotFound)) }) }) diff --git a/tests/integration/suite/ledger-revert-transaction.go b/tests/integration/suite/ledger-revert-transaction.go index 77aec8aad4..c236fb9317 100644 --- a/tests/integration/suite/ledger-revert-transaction.go +++ b/tests/integration/suite/ledger-revert-transaction.go @@ -1,15 +1,16 @@ package suite import ( + "math/big" + "net/http" + "time" + "github.com/formancehq/formance-sdk-go/pkg/models/sdkerrors" "github.com/formancehq/stack/libs/go-libs/pointer" "github.com/formancehq/stack/tests/integration/internal/modules" "github.com/nats-io/nats.go" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "math/big" - "net/http" - "time" "github.com/formancehq/formance-sdk-go/pkg/models/operations" "github.com/formancehq/formance-sdk-go/pkg/models/shared" @@ -109,7 +110,7 @@ var _ = WithModules([]*Module{modules.Ledger}, func() { JustBeforeEach(revertTx) It("Should fail", func() { Expect(err).To(HaveOccurred()) - Expect(err.(*sdkerrors.V2ErrorResponse).ErrorCode).To(Equal(sdkerrors.V2ErrorsEnumInsufficientFund)) + Expect(err.(*sdkerrors.V2ErrorResponse).ErrorCode).To(Equal(shared.V2ErrorsEnumInsufficientFund)) }) Context("With forcing", func() { BeforeEach(func() { @@ -162,7 +163,7 @@ var _ = WithModules([]*Module{modules.Ledger}, func() { }, ) Expect(err).NotTo(BeNil()) - Expect(err.(*sdkerrors.V2ErrorResponse).ErrorCode).To(Equal(sdkerrors.V2ErrorsEnumAlreadyRevert)) + Expect(err.(*sdkerrors.V2ErrorResponse).ErrorCode).To(Equal(shared.V2ErrorsEnumAlreadyRevert)) }) }) }) diff --git a/tests/integration/suite/ledger-set-metadata-on-transaction.go b/tests/integration/suite/ledger-set-metadata-on-transaction.go index 417720ff3f..2697e2c124 100644 --- a/tests/integration/suite/ledger-set-metadata-on-transaction.go +++ b/tests/integration/suite/ledger-set-metadata-on-transaction.go @@ -1,12 +1,13 @@ package suite import ( - "github.com/formancehq/formance-sdk-go/pkg/models/sdkerrors" - "github.com/formancehq/stack/tests/integration/internal/modules" "math/big" "net/http" "time" + "github.com/formancehq/formance-sdk-go/pkg/models/sdkerrors" + "github.com/formancehq/stack/tests/integration/internal/modules" + "github.com/formancehq/formance-sdk-go/pkg/models/operations" "github.com/formancehq/formance-sdk-go/pkg/models/shared" . "github.com/formancehq/stack/tests/integration/internal" @@ -77,7 +78,7 @@ var _ = WithModules([]*Module{modules.Ledger}, func() { }, ) Expect(err).To(HaveOccurred()) - Expect(err.(*sdkerrors.V2ErrorResponse).ErrorCode).To(Equal(sdkerrors.V2ErrorsEnumNotFound)) + Expect(err.(*sdkerrors.V2ErrorResponse).ErrorCode).To(Equal(shared.V2ErrorsEnumNotFound)) }) Then("adding a metadata", func() { metadata := map[string]string{ diff --git a/tests/integration/suite/orchestration-workflows-soft-delete.go b/tests/integration/suite/orchestration-workflows-soft-delete.go index 3e46b7a4ce..3df14f09bb 100644 --- a/tests/integration/suite/orchestration-workflows-soft-delete.go +++ b/tests/integration/suite/orchestration-workflows-soft-delete.go @@ -76,7 +76,7 @@ var _ = WithModules([]*Module{modules.Auth, modules.Orchestration}, func() { }, ) Expect(err).To(HaveOccurred()) - Expect(err.(*sdkerrors.V2Error).ErrorCode).To(Equal(sdkerrors.V2ErrorErrorCodeValidation)) + Expect(err.(*sdkerrors.V2Error).ErrorCode).To(Equal(sdkerrors.ErrorCodeValidation)) }) }) When("deleting a non-existing workflow", func() { @@ -88,7 +88,7 @@ var _ = WithModules([]*Module{modules.Auth, modules.Orchestration}, func() { }, ) Expect(err).To(HaveOccurred()) - Expect(err.(*sdkerrors.V2Error).ErrorCode).To(Equal(sdkerrors.V2ErrorErrorCodeNotFound)) + Expect(err.(*sdkerrors.V2Error).ErrorCode).To(Equal(sdkerrors.ErrorCodeNotFound)) }) }) }) diff --git a/tests/integration/suite/webhooks-configs-activation.go b/tests/integration/suite/webhooks-configs-activation.go index 441bb920d3..2e987ea6b8 100644 --- a/tests/integration/suite/webhooks-configs-activation.go +++ b/tests/integration/suite/webhooks-configs-activation.go @@ -111,7 +111,7 @@ var _ = WithModules([]*Module{modules.Webhooks}, func() { }, ) Expect(err).To(HaveOccurred()) - Expect(err.(*sdkerrors.WebhooksErrorResponse).ErrorCode).To(Equal(sdkerrors.WebhooksErrorsEnumNotFound)) + Expect(err.(*sdkerrors.WebhooksErrorResponse).ErrorCode).To(Equal(shared.WebhooksErrorsEnumNotFound)) }) }) }) diff --git a/tests/integration/suite/webhooks-configs-delete.go b/tests/integration/suite/webhooks-configs-delete.go index b2d3d8e7e0..29ca201c4d 100644 --- a/tests/integration/suite/webhooks-configs-delete.go +++ b/tests/integration/suite/webhooks-configs-delete.go @@ -1,9 +1,10 @@ package suite import ( + "net/http" + "github.com/formancehq/formance-sdk-go/pkg/models/sdkerrors" "github.com/formancehq/stack/tests/integration/internal/modules" - "net/http" "github.com/formancehq/formance-sdk-go/pkg/models/operations" "github.com/formancehq/formance-sdk-go/pkg/models/shared" @@ -71,7 +72,7 @@ var _ = WithModules([]*Module{modules.Webhooks}, func() { }, ) Expect(err).To(HaveOccurred()) - Expect(err.(*sdkerrors.WebhooksErrorResponse).ErrorCode).To(Equal(sdkerrors.WebhooksErrorsEnumNotFound)) + Expect(err.(*sdkerrors.WebhooksErrorResponse).ErrorCode).To(Equal(shared.WebhooksErrorsEnumNotFound)) }) }) @@ -84,7 +85,7 @@ var _ = WithModules([]*Module{modules.Webhooks}, func() { }, ) Expect(err).To(HaveOccurred()) - Expect(err.(*sdkerrors.WebhooksErrorResponse).ErrorCode).To(Equal(sdkerrors.WebhooksErrorsEnumNotFound)) + Expect(err.(*sdkerrors.WebhooksErrorResponse).ErrorCode).To(Equal(shared.WebhooksErrorsEnumNotFound)) }) }) }) diff --git a/tests/integration/suite/webhooks-configs-insert.go b/tests/integration/suite/webhooks-configs-insert.go index 2f0811ecd4..1ceb3c02e6 100644 --- a/tests/integration/suite/webhooks-configs-insert.go +++ b/tests/integration/suite/webhooks-configs-insert.go @@ -1,11 +1,12 @@ package suite import ( - "github.com/formancehq/formance-sdk-go/pkg/models/sdkerrors" - "github.com/formancehq/stack/tests/integration/internal/modules" "net/http" "time" + "github.com/formancehq/formance-sdk-go/pkg/models/sdkerrors" + "github.com/formancehq/stack/tests/integration/internal/modules" + "github.com/formancehq/formance-sdk-go/pkg/models/shared" . "github.com/formancehq/stack/tests/integration/internal" "github.com/google/uuid" @@ -62,7 +63,7 @@ var _ = WithModules([]*Module{modules.Webhooks}, func() { cfg, ) Expect(err).To(HaveOccurred()) - Expect(err.(*sdkerrors.WebhooksErrorResponse).ErrorCode).To(Equal(sdkerrors.WebhooksErrorsEnumValidation)) + Expect(err.(*sdkerrors.WebhooksErrorResponse).ErrorCode).To(Equal(shared.WebhooksErrorsEnumValidation)) }) It("inserting an invalid config with invalid secret", func() { diff --git a/tests/integration/suite/webhooks-configs-test.go b/tests/integration/suite/webhooks-configs-test.go index 1d9a4aab19..ef95653379 100644 --- a/tests/integration/suite/webhooks-configs-test.go +++ b/tests/integration/suite/webhooks-configs-test.go @@ -1,13 +1,14 @@ package suite import ( - "github.com/formancehq/formance-sdk-go/pkg/models/sdkerrors" - "github.com/formancehq/stack/tests/integration/internal/modules" "io" "net/http" "net/http/httptest" "strconv" + "github.com/formancehq/formance-sdk-go/pkg/models/sdkerrors" + "github.com/formancehq/stack/tests/integration/internal/modules" + "github.com/formancehq/formance-sdk-go/pkg/models/operations" "github.com/formancehq/formance-sdk-go/pkg/models/shared" . "github.com/formancehq/stack/tests/integration/internal" @@ -151,7 +152,7 @@ var _ = WithModules([]*Module{modules.Webhooks}, func() { }, ) Expect(err).To(HaveOccurred()) - Expect(err.(*sdkerrors.WebhooksErrorResponse).ErrorCode).To(Equal(sdkerrors.WebhooksErrorsEnumNotFound)) + Expect(err.(*sdkerrors.WebhooksErrorResponse).ErrorCode).To(Equal(shared.WebhooksErrorsEnumNotFound)) }) }) })