Files
commerce/test/util/task/task_test.go
zeekay 1943f1c093 Hanzo Commerce
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
2026-09-23 21:52:16 -07:00

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"))
}
})
})