Files
payments/pkg/domain/models/connector_tasks_tree_test.go
zeekay 7d727874d5 chore: rebrand Formance Payments -> Hanzo Payments (hanzo-fi)
- 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.
2026-07-05 13:08:55 -07:00

116 lines
3.9 KiB
Go

package models_test
import (
"testing"
"github.com/hanzo-fi/payments/pkg/domain/models"
"github.com/stretchr/testify/assert"
)
func TestTaskType(t *testing.T) {
t.Parallel()
assert.Equal(t, models.TaskType(0), models.TASK_FETCH_OTHERS)
assert.Equal(t, models.TaskType(1), models.TASK_FETCH_ACCOUNTS)
assert.Equal(t, models.TaskType(2), models.TASK_FETCH_BALANCES)
assert.Equal(t, models.TaskType(3), models.TASK_FETCH_EXTERNAL_ACCOUNTS)
assert.Equal(t, models.TaskType(4), models.TASK_FETCH_PAYMENTS)
assert.Equal(t, models.TaskType(5), models.TASK_CREATE_WEBHOOKS)
}
func TestTaskTreeStructs(t *testing.T) {
t.Parallel()
fetchOther := &models.TaskTreeFetchOther{}
fetchAccounts := &models.TaskTreeFetchAccounts{}
fetchBalances := &models.TaskTreeFetchBalances{}
fetchExternalAccounts := &models.TaskTreeFetchExternalAccounts{}
fetchPayments := &models.TaskTreeFetchPayments{}
createWebhooks := &models.TaskTreeCreateWebhooks{}
tree := models.ConnectorTaskTree{
TaskType: models.TASK_FETCH_ACCOUNTS,
Name: "fetch-accounts",
Periodically: true,
TaskTreeFetchAccounts: fetchAccounts,
TaskTreeFetchBalances: fetchBalances,
TaskTreeFetchExternalAccounts: fetchExternalAccounts,
TaskTreeFetchOther: fetchOther,
TaskTreeFetchPayments: fetchPayments,
TaskTreeCreateWebhooks: createWebhooks,
}
assert.Equal(t, models.TASK_FETCH_ACCOUNTS, tree.TaskType)
assert.Equal(t, "fetch-accounts", tree.Name)
assert.True(t, tree.Periodically)
assert.Equal(t, fetchAccounts, tree.TaskTreeFetchAccounts)
assert.Equal(t, fetchBalances, tree.TaskTreeFetchBalances)
assert.Equal(t, fetchExternalAccounts, tree.TaskTreeFetchExternalAccounts)
assert.Equal(t, fetchOther, tree.TaskTreeFetchOther)
assert.Equal(t, fetchPayments, tree.TaskTreeFetchPayments)
assert.Equal(t, createWebhooks, tree.TaskTreeCreateWebhooks)
}
func TestConnectorTaskTreeWithNextTasks(t *testing.T) {
t.Parallel()
balancesTask := models.ConnectorTaskTree{
TaskType: models.TASK_FETCH_BALANCES,
Name: "fetch-balances",
TaskTreeFetchBalances: &models.TaskTreeFetchBalances{},
}
paymentsTask := models.ConnectorTaskTree{
TaskType: models.TASK_FETCH_PAYMENTS,
Name: "fetch-payments",
TaskTreeFetchPayments: &models.TaskTreeFetchPayments{},
}
accountsTask := models.ConnectorTaskTree{
TaskType: models.TASK_FETCH_ACCOUNTS,
Name: "fetch-accounts",
TaskTreeFetchAccounts: &models.TaskTreeFetchAccounts{},
NextTasks: []models.ConnectorTaskTree{balancesTask, paymentsTask},
}
assert.Equal(t, models.TASK_FETCH_ACCOUNTS, accountsTask.TaskType)
assert.Equal(t, "fetch-accounts", accountsTask.Name)
assert.Len(t, accountsTask.NextTasks, 2)
assert.Equal(t, models.TASK_FETCH_BALANCES, accountsTask.NextTasks[0].TaskType)
assert.Equal(t, "fetch-balances", accountsTask.NextTasks[0].Name)
assert.Equal(t, models.TASK_FETCH_PAYMENTS, accountsTask.NextTasks[1].TaskType)
assert.Equal(t, "fetch-payments", accountsTask.NextTasks[1].Name)
}
func TestConnectorTasksTreeSlice(t *testing.T) {
t.Parallel()
tasksTree := models.ConnectorTasksTree{}
assert.Empty(t, tasksTree)
task1 := models.ConnectorTaskTree{
TaskType: models.TASK_FETCH_ACCOUNTS,
Name: "fetch-accounts",
}
task2 := models.ConnectorTaskTree{
TaskType: models.TASK_FETCH_BALANCES,
Name: "fetch-balances",
}
tasksTree = append(tasksTree, task1)
assert.Len(t, tasksTree, 1)
assert.Equal(t, models.TASK_FETCH_ACCOUNTS, tasksTree[0].TaskType)
tasksTree = append(tasksTree, task2)
assert.Len(t, tasksTree, 2)
assert.Equal(t, models.TASK_FETCH_BALANCES, tasksTree[1].TaskType)
tasksTree2 := models.ConnectorTasksTree{task1, task2}
assert.Len(t, tasksTree2, 2)
assert.Equal(t, models.TASK_FETCH_ACCOUNTS, tasksTree2[0].TaskType)
assert.Equal(t, models.TASK_FETCH_BALANCES, tasksTree2[1].TaskType)
}