mirror of
https://github.com/hanzoai/tasks.git
synced 2026-11-03 03:56:04 +00:00
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).
66 lines
1.8 KiB
Go
66 lines
1.8 KiB
Go
package log
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
"github.com/stretchr/testify/suite"
|
|
"go.temporal.io/sdk/log"
|
|
"github.com/hanzoai/tasks/common/log/tag"
|
|
"go.uber.org/mock/gomock"
|
|
)
|
|
|
|
type SdkLoggerSuite struct {
|
|
*require.Assertions
|
|
suite.Suite
|
|
|
|
controller *gomock.Controller
|
|
sdkLogger log.Logger
|
|
underlyingLogger *MockLogger
|
|
}
|
|
|
|
func TestSdkLoggerSuite(t *testing.T) {
|
|
suite.Run(t, &SdkLoggerSuite{})
|
|
}
|
|
|
|
func (s *SdkLoggerSuite) SetupTest() {
|
|
s.Assertions = require.New(s.T())
|
|
s.controller = gomock.NewController(s.T())
|
|
|
|
s.underlyingLogger = NewMockLogger(s.controller)
|
|
s.sdkLogger = NewSdkLogger(s.underlyingLogger)
|
|
}
|
|
|
|
func (s *SdkLoggerSuite) TearDownTest() {
|
|
s.controller.Finish()
|
|
}
|
|
|
|
func (s *SdkLoggerSuite) TestEvenKeyValPairs() {
|
|
s.underlyingLogger.EXPECT().Info("msg", tag.Any("key1", "val1"), tag.Any("key2", "val2"))
|
|
s.sdkLogger.Info("msg", "key1", "val1", "key2", "val2")
|
|
}
|
|
|
|
func (s *SdkLoggerSuite) TestOddKeyValPairs() {
|
|
s.underlyingLogger.EXPECT().Info("msg", tag.Any("key1", "val1"), tag.Any("key2", "no value"))
|
|
s.sdkLogger.Info("msg", "key1", "val1", "key2")
|
|
}
|
|
|
|
func (s *SdkLoggerSuite) TestKeyValPairsWithTag() {
|
|
s.underlyingLogger.EXPECT().Info("msg", tag.Any("key1", "val1"), tag.String("key3", "val3"), tag.Any("key2", "val2"))
|
|
s.sdkLogger.Info("msg", "key1", "val1", tag.String("key3", "val3"), "key2", "val2")
|
|
|
|
s.underlyingLogger.EXPECT().Info("msg", tag.Any("key1", "val1"), tag.Int("key3", 3), tag.Any("key2", "val2"))
|
|
s.sdkLogger.Info("msg", "key1", "val1", tag.Int("key3", 3), "key2", "val2")
|
|
|
|
}
|
|
|
|
func (s *SdkLoggerSuite) TestEmptyKeyValPairs() {
|
|
s.underlyingLogger.EXPECT().Info("msg")
|
|
s.sdkLogger.Info("msg")
|
|
}
|
|
|
|
func (s *SdkLoggerSuite) TestSingleKeyValPairs() {
|
|
s.underlyingLogger.EXPECT().Info("msg", tag.Any("key1", "no value"))
|
|
s.sdkLogger.Info("msg", "key1")
|
|
}
|