Files
tasks/temporal/cluster_metadata_loader_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

85 lines
2.2 KiB
Go

package temporal_test
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
persistencespb "github.com/hanzoai/tasks/api/persistence/v1"
"github.com/hanzoai/tasks/common/cluster"
"github.com/hanzoai/tasks/common/config"
"github.com/hanzoai/tasks/common/log"
"github.com/hanzoai/tasks/common/persistence"
"github.com/hanzoai/tasks/temporal"
"go.uber.org/mock/gomock"
)
func TestNewClusterMetadataLoader(t *testing.T) {
t.Parallel()
ctrl := gomock.NewController(t)
metadataManager := persistence.NewMockClusterMetadataManager(ctrl)
logger := log.NewNoopLogger()
loader := temporal.NewClusterMetadataLoader(metadataManager, logger)
ctx := context.Background()
svc := &config.Config{
ClusterMetadata: &cluster.Config{
CurrentClusterName: "current_cluster",
ClusterInformation: map[string]cluster.ClusterInformation{
"current_cluster": {
RPCAddress: "rpc_old",
HTTPAddress: "http_old",
},
"remote_cluster1": {
RPCAddress: "rpc_old",
HTTPAddress: "http_old",
},
},
},
}
metadataManager.EXPECT().ListClusterMetadata(gomock.Any(), gomock.Any()).Return(&persistence.ListClusterMetadataResponse{
ClusterMetadata: []*persistence.GetClusterMetadataResponse{
{
ClusterMetadata: &persistencespb.ClusterMetadata{
ClusterName: "current_cluster",
ClusterAddress: "rpc_new",
HttpAddress: "http_new",
},
},
{
ClusterMetadata: &persistencespb.ClusterMetadata{
ClusterName: "remote_cluster1",
ClusterAddress: "rpc_new",
HttpAddress: "http_new",
},
},
{
ClusterMetadata: &persistencespb.ClusterMetadata{
ClusterName: "remote_cluster2",
ClusterAddress: "rpc_new",
HttpAddress: "http_new",
},
},
},
}, nil)
err := loader.LoadAndMergeWithStaticConfig(ctx, svc)
require.NoError(t, err)
assert.Equal(t, map[string]cluster.ClusterInformation{
"current_cluster": {
RPCAddress: "rpc_old",
HTTPAddress: "http_new",
},
"remote_cluster1": {
RPCAddress: "rpc_new",
HTTPAddress: "http_new",
},
"remote_cluster2": {
RPCAddress: "rpc_new",
HTTPAddress: "http_new",
},
}, svc.ClusterMetadata.ClusterInformation)
}