mirror of
https://github.com/hanzoai/commerce.git
synced 2026-10-30 15:08:42 +00:00
Multi-tenant commerce and billing: orders, subscriptions, invoices, plans, usage metering and a credit ledger. One Go binary. MIT OR Apache-2.0. Claude-Session: https://claude.ai/code/session_01SAtaDFm8VDiWrhYHNNtxMw
56 lines
1.0 KiB
Go
56 lines
1.0 KiB
Go
package test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/hanzoai/commerce/datastore"
|
|
"github.com/hanzoai/commerce/models/payment"
|
|
"github.com/hanzoai/commerce/util/test/ae"
|
|
|
|
. "github.com/hanzoai/commerce/util/test/ginkgo"
|
|
)
|
|
|
|
func Test(t *testing.T) {
|
|
Setup("models/payment", t)
|
|
}
|
|
|
|
var (
|
|
ctx ae.Context
|
|
db *datastore.Datastore
|
|
)
|
|
|
|
// Setup test context
|
|
var _ = BeforeSuite(func() {
|
|
ctx = ae.NewContext()
|
|
db = datastore.New(ctx)
|
|
})
|
|
|
|
// Tear-down test context
|
|
var _ = AfterSuite(func() {
|
|
ctx.Close()
|
|
})
|
|
|
|
var _ = Describe("Payment", func() {
|
|
Context("New payment", func() {
|
|
var pay *payment.Payment
|
|
|
|
Before(func() {
|
|
pay = payment.Fake(db)
|
|
})
|
|
|
|
It("should save new payments", func() {
|
|
pay.MustPut()
|
|
})
|
|
|
|
It("should correctly persist metadata", func() {
|
|
pay.Metadata["a"] = 1
|
|
pay.Metadata["orderId"] = "some-order"
|
|
pay.MustPut()
|
|
pay2 := payment.New(db)
|
|
pay2.MustGet(pay.Key())
|
|
Expect(pay2.Metadata["a"]).To(Equal(float64(1)))
|
|
Expect(pay2.Metadata["orderId"]).To(Equal("some-order"))
|
|
})
|
|
})
|
|
})
|