argo-cd/gitops-engine/pkg/utils/tracing/logging_test.go
Blake Pettersson 3dcc91cb3a
chore(gitops-engine): migrate to mockery (#27696)
Signed-off-by: Blake Pettersson <blake.pettersson@gmail.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-05-05 13:02:34 -04:00

26 lines
848 B
Go

package tracing
import (
"testing"
"github.com/go-logr/logr"
"github.com/stretchr/testify/mock"
"github.com/argoproj/argo-cd/gitops-engine/pkg/utils/tracing/mocks"
)
func TestLoggingTracer(t *testing.T) {
l := mocks.NewLogSink(t)
initCall := l.EXPECT().Init(mock.Anything).Return().Once()
withBaggageCall := l.EXPECT().WithValues("my-key", "my-value").Return(l).Once()
withOperationCall := l.EXPECT().WithValues("operation_name", "my-operation", "time_ms", mock.Anything).Return(l).Once()
enabledCall := l.EXPECT().Enabled(mock.Anything).Return(true).Once()
infoCall := l.EXPECT().Info(0, "Trace").Return().Once()
mock.InOrder(initCall, withBaggageCall, withOperationCall, enabledCall, infoCall)
tr := NewLoggingTracer(logr.New(l))
span := tr.StartSpan("my-operation")
span.SetBaggageItem("my-key", "my-value")
span.Finish()
}