Files
tasks/common/protocol/naming_test.go
zeekay 5a601d081b rebrand: go.temporal.io/server -> github.com/hanzoai/tasks
Full module path rebrand from Temporal to Hanzo Tasks:
- go.mod module: github.com/hanzoai/tasks
- All internal Go imports updated (1906 files)
- cmd/server renamed to cmd/tasksd
- Binary name: tasksd (was temporal-server)
- Docker images: hanzoai/tasks (was temporalio/server)
- README rewritten with Hanzo Tasks branding
- LLM.md created with integration notes
- Makefile, goreleaser, CI workflows updated
- go.temporal.io/sdk and go.temporal.io/api imports preserved (separate repos)

Fork of Temporal.io (MIT license).
2026-03-19 10:36:40 -07:00

57 lines
1.3 KiB
Go

package protocol_test
import (
"testing"
"github.com/stretchr/testify/require"
protocolpb "go.temporal.io/api/protocol/v1"
"github.com/hanzoai/tasks/common/protocol"
"google.golang.org/protobuf/types/known/anypb"
"google.golang.org/protobuf/types/known/emptypb"
)
func TestNilSafety(t *testing.T) {
t.Parallel()
t.Run("nil message", func(t *testing.T) {
pt, mt := protocol.IdentifyOrUnknown(nil)
require.Equal(t, protocol.TypeUnknown, pt)
require.Equal(t, protocol.MessageTypeUnknown, mt)
})
t.Run("nil message body", func(t *testing.T) {
pt, mt := protocol.IdentifyOrUnknown(&protocolpb.Message{})
require.Equal(t, protocol.TypeUnknown, pt)
require.Equal(t, protocol.MessageTypeUnknown, mt)
})
}
func TestWithValidMessage(t *testing.T) {
t.Parallel()
var empty emptypb.Empty
var body anypb.Any
require.NoError(t, body.MarshalFrom(&empty))
msg := protocolpb.Message{Body: &body}
pt, mt := protocol.IdentifyOrUnknown(&msg)
require.Equal(t, "google.protobuf", pt.String())
require.Equal(t, "google.protobuf.Empty", mt.String())
}
func TestWithInvalidBody(t *testing.T) {
t.Parallel()
var empty emptypb.Empty
var body anypb.Any
require.NoError(t, body.MarshalFrom(&empty))
msg := protocolpb.Message{Body: &body}
msg.Body.TypeUrl = "this isn't valid"
_, _, err := protocol.Identify(&msg)
require.Error(t, err)
}