Files
open-cluster-management/pkg/common/testing/fake_sync_context.go
Jian Qiu 33310619d9 🌱 use SDK basecontroller for better logging. (#1269)
* Use basecontroller in sdk-go instead for better logging

Signed-off-by: Jian Qiu <jqiu@redhat.com>

* Rename to fakeSyncContext

Signed-off-by: Jian Qiu <jqiu@redhat.com>

---------

Signed-off-by: Jian Qiu <jqiu@redhat.com>
2025-12-01 03:07:02 +00:00

29 lines
778 B
Go

package testing
import (
"testing"
"k8s.io/client-go/util/workqueue"
sdkevents "open-cluster-management.io/sdk-go/pkg/basecontroller/events"
)
type FakeSyncContext struct {
spokeName string
recorder sdkevents.Recorder
queue workqueue.TypedRateLimitingInterface[string]
}
func (f FakeSyncContext) Queue() workqueue.TypedRateLimitingInterface[string] { return f.queue }
func (f FakeSyncContext) Recorder() sdkevents.Recorder {
return f.recorder
}
func NewFakeSyncContext(t *testing.T, clusterName string) *FakeSyncContext {
return &FakeSyncContext{
spokeName: clusterName,
recorder: sdkevents.NewContextualLoggingEventRecorder(t.Name()),
queue: workqueue.NewTypedRateLimitingQueue[string](workqueue.DefaultTypedControllerRateLimiter[string]()),
}
}