mirror of
https://github.com/hanzo-fi/payments.git
synced 2026-10-30 20:31:20 +00:00
- go.mod module path + all self-imports: github.com/formancehq/payments -> github.com/hanzo-fi/payments (1590 .go files / 3152 refs; 20 modules: root, pkg/client, pkg/domain, 18 ce/plugins). External dep kept: formancehq/go-libs. - plugins: each ce/plugins/* consumed a *published* pkg/domain; added local 'replace .../pkg/domain => ../../../pkg/domain' (consistent with root) so every standalone plugin module builds in-monorepo. compile-plugin.sh MOD var rebranded too. - branding: README, LICENSE (dual MIT+EE; upstream copyright retained + Hanzo added), goreleaser (release images -> registry.hanzo.ai/hanzo-fi, OCI labels, homepage), proto go_package, renovate, speakeasy gen.yaml, connector-template *.gotpl. - CI: removed Numary/Formance workflows + composite action; added canonical hanzo.yml + cicd.yml (hanzoai/ci, gated HANZO_CI_ENABLED) + secretless ci.yml (go build/vet). - kept as data/compat keys: wire capability enums ALLOW_FORMANCE_*, generated SDK type client.Formance, domain field FormanceRedirectURL, OTEL_SERVICE_NAME, upstream base image. - verified: go build ./... (default + -tags ee) + all 20 nested modules green.
178 lines
5.7 KiB
Go
178 lines
5.7 KiB
Go
package workflow
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
|
|
"github.com/hanzo-fi/payments/internal/connectors/engine/activities"
|
|
"github.com/hanzo-fi/payments/pkg/domain/models"
|
|
"github.com/stretchr/testify/mock"
|
|
"go.temporal.io/sdk/temporal"
|
|
)
|
|
|
|
func (s *UnitTestSuite) Test_CreateWebhooks_Success() {
|
|
s.env.OnActivity(activities.PluginCreateWebhooksActivity, mock.Anything, mock.Anything).Once().Return(func(ctx context.Context, req activities.CreateWebhooksRequest) (*models.CreateWebhooksResponse, error) {
|
|
s.Equal(s.connectorID, req.ConnectorID)
|
|
s.Equal(s.connectorID.String(), req.Req.ConnectorID)
|
|
s.Equal("http://localhost:8080/api/payments/v3/connectors/webhooks/"+s.connectorID.String(), req.Req.WebhookBaseUrl)
|
|
return &models.CreateWebhooksResponse{
|
|
Others: []models.PSPOther{
|
|
{
|
|
ID: "test",
|
|
Other: []byte(`{}`),
|
|
},
|
|
},
|
|
Configs: []models.PSPWebhookConfig{
|
|
{
|
|
Name: "test",
|
|
URLPath: "/test",
|
|
},
|
|
},
|
|
}, nil
|
|
})
|
|
s.env.OnActivity(activities.StorageWebhooksConfigsStoreActivity, mock.Anything, mock.Anything).Once().Return(func(ctx context.Context, configs []models.WebhookConfig) error {
|
|
return nil
|
|
})
|
|
|
|
s.env.ExecuteWorkflow(RunCreateWebhooks, CreateWebhooks{
|
|
ConnectorID: s.connectorID,
|
|
FromPayload: nil,
|
|
}, []models.ConnectorTaskTree{})
|
|
|
|
s.True(s.env.IsWorkflowCompleted())
|
|
err := s.env.GetWorkflowError()
|
|
s.NoError(err)
|
|
}
|
|
|
|
func (s *UnitTestSuite) Test_CreateWebhooks_WithNextTasks_Success() {
|
|
s.env.OnActivity(activities.PluginCreateWebhooksActivity, mock.Anything, mock.Anything).Once().Return(func(ctx context.Context, req activities.CreateWebhooksRequest) (*models.CreateWebhooksResponse, error) {
|
|
s.Equal(s.connectorID, req.ConnectorID)
|
|
s.Equal(s.connectorID.String(), req.Req.ConnectorID)
|
|
s.Equal("http://localhost:8080/api/payments/v3/connectors/webhooks/"+s.connectorID.String(), req.Req.WebhookBaseUrl)
|
|
return &models.CreateWebhooksResponse{
|
|
Others: []models.PSPOther{
|
|
{
|
|
ID: "test",
|
|
Other: []byte(`{}`),
|
|
},
|
|
},
|
|
Configs: []models.PSPWebhookConfig{
|
|
{
|
|
Name: "test",
|
|
URLPath: "/test",
|
|
},
|
|
},
|
|
}, nil
|
|
})
|
|
s.env.OnActivity(activities.StorageWebhooksConfigsStoreActivity, mock.Anything, mock.Anything).Once().Return(func(ctx context.Context, configs []models.WebhookConfig) error {
|
|
return nil
|
|
})
|
|
s.env.OnActivity(activities.StorageSchedulesStoreActivity, mock.Anything, mock.Anything).Once().Return(nil)
|
|
s.env.OnActivity(activities.TemporalScheduleCreateActivity, mock.Anything, mock.Anything).Once().Return(nil)
|
|
|
|
s.env.ExecuteWorkflow(RunCreateWebhooks, CreateWebhooks{
|
|
ConnectorID: s.connectorID,
|
|
FromPayload: nil,
|
|
}, []models.ConnectorTaskTree{
|
|
{
|
|
TaskType: models.TASK_FETCH_OTHERS,
|
|
Name: "test",
|
|
Periodically: true,
|
|
},
|
|
})
|
|
|
|
s.True(s.env.IsWorkflowCompleted())
|
|
err := s.env.GetWorkflowError()
|
|
s.NoError(err)
|
|
}
|
|
|
|
func (s *UnitTestSuite) Test_CreateWebhooks_WithNextTasks_ConnectorScheduledForDeletion_Success() {
|
|
s.configuredConnector.ScheduledForDeletion = true
|
|
_, _, err := s.w.connectors.Load(s.configuredConnector, true, false)
|
|
s.NoError(err)
|
|
s.env.OnActivity(activities.PluginCreateWebhooksActivity, mock.Anything, mock.Anything).Once().Return(func(ctx context.Context, req activities.CreateWebhooksRequest) (*models.CreateWebhooksResponse, error) {
|
|
s.Equal(s.connectorID, req.ConnectorID)
|
|
s.Equal(s.connectorID.String(), req.Req.ConnectorID)
|
|
s.Equal("http://localhost:8080/api/payments/v3/connectors/webhooks/"+s.connectorID.String(), req.Req.WebhookBaseUrl)
|
|
return &models.CreateWebhooksResponse{
|
|
Others: []models.PSPOther{
|
|
{
|
|
ID: "test",
|
|
Other: []byte(`{}`),
|
|
},
|
|
},
|
|
Configs: []models.PSPWebhookConfig{
|
|
{
|
|
Name: "test",
|
|
URLPath: "/test",
|
|
},
|
|
},
|
|
}, nil
|
|
})
|
|
s.env.OnActivity(activities.StorageWebhooksConfigsStoreActivity, mock.Anything, mock.Anything).Once().Return(func(ctx context.Context, configs []models.WebhookConfig) error {
|
|
return nil
|
|
})
|
|
|
|
s.env.ExecuteWorkflow(RunCreateWebhooks, CreateWebhooks{
|
|
ConnectorID: s.connectorID,
|
|
FromPayload: nil,
|
|
}, []models.ConnectorTaskTree{
|
|
{
|
|
TaskType: models.TASK_FETCH_OTHERS,
|
|
Name: "test",
|
|
Periodically: true,
|
|
},
|
|
})
|
|
|
|
s.True(s.env.IsWorkflowCompleted())
|
|
err = s.env.GetWorkflowError()
|
|
s.NoError(err)
|
|
}
|
|
|
|
func (s *UnitTestSuite) Test_CreateWebhooks_PluginCreateWebhooksActivity_Error() {
|
|
s.env.OnActivity(activities.PluginCreateWebhooksActivity, mock.Anything, mock.Anything).Once().Return(
|
|
nil,
|
|
temporal.NewNonRetryableApplicationError("error-test", "PLUGIN", errors.New("error-test")),
|
|
)
|
|
|
|
s.env.ExecuteWorkflow(RunCreateWebhooks, CreateWebhooks{
|
|
ConnectorID: s.connectorID,
|
|
FromPayload: nil,
|
|
}, []models.ConnectorTaskTree{})
|
|
|
|
s.True(s.env.IsWorkflowCompleted())
|
|
err := s.env.GetWorkflowError()
|
|
s.Error(err)
|
|
s.ErrorContains(err, "error-test")
|
|
}
|
|
|
|
func (s *UnitTestSuite) Test_CreateWebhooks_StorageWebhooksConfigsStoreActivity_Error() {
|
|
s.env.OnActivity(activities.PluginCreateWebhooksActivity, mock.Anything, mock.Anything).Once().Return(&models.CreateWebhooksResponse{
|
|
Others: []models.PSPOther{
|
|
{
|
|
ID: "test",
|
|
Other: []byte(`{}`),
|
|
},
|
|
},
|
|
Configs: []models.PSPWebhookConfig{
|
|
{
|
|
Name: "test",
|
|
URLPath: "/test",
|
|
},
|
|
},
|
|
}, nil)
|
|
s.env.OnActivity(activities.StorageWebhooksConfigsStoreActivity, mock.Anything, mock.Anything).Once().Return(func(ctx context.Context, configs []models.WebhookConfig) error {
|
|
return temporal.NewNonRetryableApplicationError("error-test", "STORAGE", errors.New("error-test"))
|
|
})
|
|
|
|
s.env.ExecuteWorkflow(RunCreateWebhooks, CreateWebhooks{
|
|
ConnectorID: s.connectorID,
|
|
FromPayload: nil,
|
|
}, []models.ConnectorTaskTree{})
|
|
|
|
s.True(s.env.IsWorkflowCompleted())
|
|
err := s.env.GetWorkflowError()
|
|
s.Error(err)
|
|
s.ErrorContains(err, "error-test")
|
|
}
|