Files
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

87 lines
2.3 KiB
Go

package v3
import (
"bytes"
"context"
"encoding/json"
"io"
"log"
"net/http"
"net/http/httptest"
"testing"
"github.com/hanzo-fi/payments/pkg/domain/models"
"github.com/go-chi/chi/v5"
"github.com/google/uuid"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
func TestV3Handlers(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "API v3 Suite")
}
func generateTextString(l int) string {
var buf bytes.Buffer
for i := 0; i < l; i++ {
buf.WriteString("a")
}
return buf.String()
}
func testConnectorID() *models.ConnectorID {
return &models.ConnectorID{Reference: uuid.New(), Provider: "dummypay"}
}
func assertExpectedResponse(res *http.Response, expectedStatusCode int, expectedBodyString string) {
defer res.Body.Close()
Expect(res.StatusCode).To(Equal(expectedStatusCode))
data, err := io.ReadAll(res.Body)
Expect(err).To(BeNil())
Expect(string(data)).To(ContainSubstring(expectedBodyString))
}
func prepareJSONRequest(method string, a any) *http.Request {
b, err := json.Marshal(a)
Expect(err).To(BeNil())
body := bytes.NewReader(b)
return httptest.NewRequest(method, "/", body)
}
func prepareJSONRequestWithQuery(method string, key string, val string, a any) *http.Request {
b, err := json.Marshal(a)
Expect(err).To(BeNil())
body := bytes.NewReader(b)
return prepareQueryRequestWithBody(method, body, key, val)
}
func prepareQueryRequest(method string, args ...string) *http.Request {
return prepareQueryRequestWithBody(method, nil, args...)
}
func prepareQueryRequestWithBody(method string, body io.Reader, args ...string) *http.Request {
req := httptest.NewRequest(method, "/", body)
rctx := chi.NewRouteContext()
appendToRouteContext(rctx, args...)
return req.WithContext(context.WithValue(req.Context(), chi.RouteCtxKey, rctx))
}
func prepareQueryRequestWithPath(path string, args ...string) *http.Request {
req := httptest.NewRequest(http.MethodGet, path, nil)
rctx := chi.NewRouteContext()
appendToRouteContext(rctx, args...)
return req.WithContext(context.WithValue(req.Context(), chi.RouteCtxKey, rctx))
}
func appendToRouteContext(rctx *chi.Context, args ...string) {
if len(args)%2 != 0 {
log.Fatalf("arguments must be provided in key value pairs: %s", args)
}
for i := 0; i < len(args); i += 2 {
val := args[i+1]
rctx.URLParams.Add(args[i], val)
}
}