argo-cd/pkg/utils/tracing/logging_test.go
Ramon Rüttimann b560016286
chore(deps): bump k8s.io/kubernetes from 1.22.2 to 1.23.1 (#365)
This commit bumps the k8s.io/kubernetes dependencies and all other
kubernetes deps to 1.23.1. There have been two breakages with the
upgrade:
- The `apply.NewApplyOptions` in the kubectl libraries [has been
  removed / refactored](8165f83007 (diff-2672399cb3d708d5fed859b0a74387522408ab868b1c2457587b39cabe2b75ce))
  and split up into `ApplyOptions` and `ApplyFlags`. This commit
  populates the `ApplyOptions` directly, as going through
  the `ApplyFlags` and then calling `ToOptions()` is almost impossible
  due to its arguments.
- The `github.com/go-logr/logr` package has had some breaking changes
  between the previous alpha release `v.0.4.0` and its stable release
  `v1.0.0`. The generated mock has been updated to use `logr.LogSink`
  instead (`logr.Logger` is not an interface anymore), and the test code
  has been updated accordingly.
- Go has been updated to 1.17.6, as `sigs.k8s.io/json` depends on it.

Signed-off-by: Ramon Rüttimann <ramon@nine.ch>

apply reviewer notes: bump golang version; add missing ApplyOptions parameters

Signed-off-by: Alexander Matyushentsev <AMatyushentsev@gmail.com>
2022-01-19 13:11:47 -08:00

28 lines
701 B
Go

package tracing
import (
"testing"
"github.com/go-logr/logr"
"github.com/golang/mock/gomock"
"github.com/argoproj/gitops-engine/pkg/utils/tracing/tracer_testing"
)
func TestLoggingTracer(t *testing.T) {
c := gomock.NewController(t)
l := tracer_testing.NewMockLogSink(c)
gomock.InOrder(
l.EXPECT().Init(gomock.Any()),
l.EXPECT().WithValues("my-key", "my-value").Return(l),
l.EXPECT().WithValues("operation_name", "my-operation", "time_ms", gomock.Any()).Return(l),
l.EXPECT().Enabled(gomock.Any()).Return(true),
l.EXPECT().Info(0, "Trace"),
)
tr := NewLoggingTracer(logr.New(l))
span := tr.StartSpan("my-operation")
span.SetBaggageItem("my-key", "my-value")
span.Finish()
}