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
51 lines
1.0 KiB
Go
51 lines
1.0 KiB
Go
package test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/hanzoai/commerce/util/task"
|
|
. "github.com/hanzoai/commerce/util/test/ginkgo"
|
|
)
|
|
|
|
func Test(t *testing.T) {
|
|
Setup("util/task", t)
|
|
}
|
|
|
|
var _ = Describe("Register", func() {
|
|
It("Should add task to registry", func() {
|
|
t := new(task.Task)
|
|
t.Name = "foo"
|
|
|
|
Expect(len(task.Registry["foo"])).To(Equal(0))
|
|
task.Register("foo", t)
|
|
Expect(len(task.Registry["foo"])).To(Equal(1))
|
|
})
|
|
|
|
It("Should append additional tasks when name is re-used", func() {
|
|
t := new(task.Task)
|
|
t.Name = "bar"
|
|
|
|
task.Register("bar", t)
|
|
Expect(len(task.Registry["bar"])).To(Equal(1))
|
|
|
|
task.Register("bar", t)
|
|
Expect(len(task.Registry["bar"])).To(Equal(2))
|
|
|
|
for _, v := range task.Registry["bar"] {
|
|
Expect(v.Name).To(Equal("bar"))
|
|
}
|
|
})
|
|
|
|
It("Should append multiple tasks at once", func() {
|
|
t := new(task.Task)
|
|
t.Name = "baz"
|
|
|
|
task.Register("baz", t, t, t)
|
|
Expect(len(task.Registry["baz"])).To(Equal(3))
|
|
|
|
for _, v := range task.Registry["baz"] {
|
|
Expect(v.Name).To(Equal("baz"))
|
|
}
|
|
})
|
|
})
|