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
49 lines
839 B
Go
49 lines
839 B
Go
package test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/hanzoai/commerce/datastore"
|
|
"github.com/hanzoai/commerce/models/coupon"
|
|
"github.com/hanzoai/commerce/util/test/ae"
|
|
|
|
. "github.com/hanzoai/commerce/util/test/ginkgo"
|
|
)
|
|
|
|
func Test(t *testing.T) {
|
|
Setup("models/coupon", 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("Coupon", func() {
|
|
Context("GetById", func() {
|
|
var cpn *coupon.Coupon
|
|
|
|
Before(func() {
|
|
cpn = coupon.Fake(db)
|
|
cpn.MustCreate()
|
|
})
|
|
|
|
It("should retrieve coupon from datastore by code", func() {
|
|
cpn2 := coupon.New(db)
|
|
cpn2.MustGetById(cpn.Code())
|
|
Expect(cpn2.Code()).To(Equal(cpn2.Code()))
|
|
})
|
|
})
|
|
})
|