Files
tasks/components/nexusoperations/build_callback_url_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

62 lines
2.0 KiB
Go

package nexusoperations
import (
"testing"
"github.com/stretchr/testify/require"
persistencespb "github.com/hanzoai/tasks/api/persistence/v1"
"github.com/hanzoai/tasks/common/namespace"
)
func TestBuildCallbackURL(t *testing.T) {
ns := namespace.NewLocalNamespaceForTest(
&persistencespb.NamespaceInfo{Name: "ns-name", Id: "ns-id"},
&persistencespb.NamespaceConfig{},
"active-cluster",
)
workerEndpoint := &persistencespb.NexusEndpointEntry{
Endpoint: &persistencespb.NexusEndpoint{
Spec: &persistencespb.NexusEndpointSpec{
Name: "endpoint",
Target: &persistencespb.NexusEndpointTarget{
Variant: &persistencespb.NexusEndpointTarget_Worker_{
Worker: &persistencespb.NexusEndpointTarget_Worker{
NamespaceId: "ns-id",
TaskQueue: "nexus-tq",
},
},
},
},
},
}
externalEndpoint := &persistencespb.NexusEndpointEntry{
Endpoint: &persistencespb.NexusEndpoint{
Spec: &persistencespb.NexusEndpointSpec{
Name: "endpoint",
Target: &persistencespb.NexusEndpointTarget{
Variant: &persistencespb.NexusEndpointTarget_External_{
External: &persistencespb.NexusEndpointTarget_External{Url: "https://api.example.com"},
},
},
},
},
}
// When UseSystemCallbackURL is true and target is worker, return the system URL
got, err := buildCallbackURL(true, "http://example/callback/{{.NamespaceName}}", ns, workerEndpoint)
require.NoError(t, err)
require.Equal(t, "temporal://system", got)
// When UseSystemCallbackURL is true but target is external, use the template
got, err = buildCallbackURL(true, "http://example/callback/{{.NamespaceName}}-{{.NamespaceID}}", ns, externalEndpoint)
require.NoError(t, err)
require.Equal(t, "http://example/callback/ns-name-ns-id", got)
// When UseSystemCallbackURL is false, always use the template
got, err = buildCallbackURL(false, "https://cb/{{.NamespaceID}}/{{.NamespaceName}}", ns, workerEndpoint)
require.NoError(t, err)
require.Equal(t, "https://cb/ns-id/ns-name", got)
}