snapshot of https://github.com/ThreeDotsLabs/watermill.git (master, 2026-09-15; blobs > 131072B omitted)
Some checks failed
master / ci (push) Failing after 0s
Some checks failed
master / ci (push) Failing after 0s
This commit is contained in:
49
components/cqrs/name_test.go
Normal file
49
components/cqrs/name_test.go
Normal file
@@ -0,0 +1,49 @@
|
||||
package cqrs_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/ThreeDotsLabs/watermill/components/cqrs"
|
||||
)
|
||||
|
||||
func TestFullyQualifiedStructName(t *testing.T) {
|
||||
type Object struct{}
|
||||
|
||||
assert.Equal(t, "cqrs_test.Object", cqrs.FullyQualifiedStructName(Object{}))
|
||||
assert.Equal(t, "cqrs_test.Object", cqrs.FullyQualifiedStructName(&Object{}))
|
||||
}
|
||||
|
||||
func BenchmarkFullyQualifiedStructName(b *testing.B) {
|
||||
type Object struct{}
|
||||
o := Object{}
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
cqrs.FullyQualifiedStructName(o)
|
||||
}
|
||||
}
|
||||
|
||||
func TestStructName(t *testing.T) {
|
||||
type Object struct{}
|
||||
|
||||
assert.Equal(t, "Object", cqrs.StructName(Object{}))
|
||||
assert.Equal(t, "Object", cqrs.StructName(&Object{}))
|
||||
}
|
||||
|
||||
func TestNamedStruct(t *testing.T) {
|
||||
assert.Equal(t, "named object", cqrs.NamedStruct(cqrs.StructName)(namedObject{}))
|
||||
assert.Equal(t, "named object", cqrs.NamedStruct(cqrs.StructName)(&namedObject{}))
|
||||
|
||||
// Test fallback
|
||||
type Object struct{}
|
||||
|
||||
assert.Equal(t, "Object", cqrs.NamedStruct(cqrs.StructName)(Object{}))
|
||||
assert.Equal(t, "Object", cqrs.NamedStruct(cqrs.StructName)(&Object{}))
|
||||
}
|
||||
|
||||
type namedObject struct{}
|
||||
|
||||
func (namedObject) Name() string {
|
||||
return "named object"
|
||||
}
|
||||
Reference in New Issue
Block a user