Files
tasks/common/persistence/nosql/nosqlplugin/cassandra/gocql/session_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

60 lines
1.8 KiB
Go

package gocql
import (
"errors"
"testing"
"time"
"github.com/gocql/gocql"
"github.com/stretchr/testify/assert"
"github.com/hanzoai/tasks/common"
"github.com/hanzoai/tasks/common/log"
"github.com/hanzoai/tasks/common/metrics"
"go.uber.org/mock/gomock"
)
func TestSessionEmitsMetricOnRefreshError(t *testing.T) {
controller := gomock.NewController(t)
metricsHandler := metrics.NewMockHandler(controller)
s := session{
status: common.DaemonStatusStarted,
newClusterConfigFunc: func() (*gocql.ClusterConfig, error) {
return nil, errors.New("mock error for failing cluster creation")
},
logger: log.NewNoopLogger(),
metricsHandler: metricsHandler,
}
metricsHandler.EXPECT().WithTags(metrics.FailureTag(refreshErrorTagValue)).Return(metricsHandler)
metricsHandler.EXPECT().Counter(metrics.CassandraSessionRefreshFailures.Name()).Return(metrics.NoopCounterMetricFunc)
s.refresh()
controller.Finish()
}
func TestSessionEmitsMetricOnRefreshThrottle(t *testing.T) {
controller := gomock.NewController(t)
metricsHandler := metrics.NewMockHandler(controller)
s := session{
status: common.DaemonStatusStarted,
logger: log.NewNoopLogger(),
metricsHandler: metricsHandler,
sessionInitTime: time.Now().UTC(),
}
metricsHandler.EXPECT().WithTags(metrics.FailureTag(refreshThrottleTagValue)).Return(metricsHandler)
metricsHandler.EXPECT().Counter(metrics.CassandraSessionRefreshFailures.Name()).Return(metrics.NoopCounterMetricFunc)
s.refresh()
controller.Finish()
}
func TestPanicCapture(t *testing.T) {
_, err := initSession(log.NewNoopLogger(), func() (*gocql.ClusterConfig, error) {
return &gocql.ClusterConfig{Hosts: []string{"0.0.0.0"}}, nil
}, metrics.NoopMetricsHandler)
assert.Error(t, err)
assert.Contains(t, err.Error(), "panic:")
}